Kyle
Kyle

Reputation: 2379

XSL select value of an attribute

So I probably didn't word the title well. But, what I want to do is given the following xml excerpt:

<id name="tim" number="5555665" />

I would like to pull out the actual name and number of id. I have tried:

<xsl:value-of select="id.name"/>
AND
<xsl:value-of select="id/name"/>

Neither of which have done the trick. How can I access these data values?

Upvotes: 0

Views: 775

Answers (2)

Vinit
Vinit

Reputation: 1825

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

<xsl:value-of select="id/@number"/>

Upvotes: 1

Buck Doyle
Buck Doyle

Reputation: 6397

To select attribute values with XPath, use the @ selector:

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

Upvotes: 3

Related Questions