Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl:value-of select attrribue 1

Status
Not open for further replies.

elleryh

Programmer
Jul 16, 2004
4
US
First of all, I am not very experienced in xml.

There is an xml stylesheet using this format:
<xsl:for-each select="depthem">
Depth Encoding Method: <xsl:value-of/>
</xsl:for-each>


It seems like a select attribute is required in xsl:value-of, but I'm not sure what to use to replace it?
 
Code:
<xsl:for-each select="depthem">
 Depth Encoding Method: <xsl:value-of/>
</xsl:for-each>

The xsl:for-each lets you loop through a series of repeated elements. So if depthem occurs multiple times in the context node, you will loop over each element. If you are looking to print the value of either a child, an attribute or text, then you use the <xsl:value-of select=""/> to display that value.

Code:
<!-- Select the current nodes text -->
<xsl:value-of select="."/> or <xsl:value-of select="text()"/>

<!-- Select the current nodes attribute -->
<xsl:value-of select="@ATTRIBUTE_NAME"/>

<!-- Select the current nodes child -->
<xsl:value-of select="CHILD_NAME"/>

-jay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top