在XML中获取属性的值


145

如何使用xslt在以下xml中获取attribute1(blah)的值:

<name attribute1="blah" attribute2="blahblah">
</name>

Answers:


270

这更多的是xpath问题,但是像这样,假设上下文是父元素:

<xsl:value-of select="name/@attribute1" />

如果上下文不在父元素中怎么办?
Arty

3
同样,这将是一个xpath问题;
numX 2015年

2
@Arty-我想您正在寻找的只是xsl:value-of select =“ ./@ attributename”
Sidharth Ramesh
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.