Click to See Complete Forum and Search --> : Issues with displaying an element in XSLT


maizey
12-15-2004, 09:27 AM
I have the following XML document (shorterned):

<specials>
<cd>Kind of Blue
<artist>Miles Davis</artist>
<price>$11.99</price>
<track length="9:22">So What</track>
</cd>
</specials>


At the moment, in my XSLT file, I am referencing the elements simply using:

<xsl:value-of select="artist" />

However, this won't work for the element 'cd'. How do I display the element CD in my XSLT?

Would appreciate any help, thanks.

mark van daalen
12-17-2004, 10:14 AM
try either:

<specials>
<cd>
<cdName>Kind of Blue</cdName>
<artist>Miles Davis</artist>
<price>$11.99</price>
<track length="9:22">So What</track>
</cd>
</specials>

with
<xsl:value-of select="cdname"/>

or

<specials>
<cd name="Kind of Blue">
<artist>Miles Davis</artist>
<price>$11.99</price>
<track length="9:22">So What</track>
</cd>
</specials>

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

Alantin
12-30-2004, 10:28 AM
Try <xsl:value-of select="cd/text()[1]"/> to select the first text node.