XML
Attributes can make things a lot easier. For example, our previous XMl document could be changed so that it uses attributes quite easily:
<people> <person name="Sam Huggill"email="sam@vbsquare.com"/> <person name="Sam Huggill"email="sam@vbsquare.com"/>> </people>
We can read attributes by using the <xsl:value-of> tag and prefixing the attribute name with an @ sign:
<xsl:value-ofselect="people/person/@name"> <xsl:value-ofselect="people/person/@email">
Our loop now looks like this:
<xsl:for-eachselect="people/person"> <xsl:value-of select="@name"/> <xsl:value-of select="@email"/> </xsl:for-each>
Page 3 of 6
This article was originally published on November 20, 2002