172

How would one get the value of attribute1 (blah) in the following xml using xslt:

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

1 Answer 1

308

This is more of an xpath question, but like this, assuming the context is the parent element:

<xsl:value-of select="name/@attribute1" />
4
  • What if the context is not in the parent element?
    – Arty
    Commented Mar 24, 2015 at 17:31
  • 3
    again, this would be an xpath question ;
    – numX
    Commented Nov 14, 2015 at 15:34
  • 9
    @Arty - I think what you're looking for is simply xsl:value-of select="./@attributename" Commented Apr 28, 2020 at 13:38
  • Can't it be simply @attribute1?
    – U. Windl
    Commented Feb 16, 2023 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.