How to make conditions or filter the xml node using XSL
-
Hi, I am just new to XSL. Hope anyone can help regarding my problem. Problem: I only want to display the node for ITEM/DESC and ITEM1/DESC1. How to make conditions or file the xml using XSL. THank you. jollymj23 Sample.xsl Sample.xml ITEM DESC ITEM1 DESC1 ORDER DESC
-
Hi, I am just new to XSL. Hope anyone can help regarding my problem. Problem: I only want to display the node for ITEM/DESC and ITEM1/DESC1. How to make conditions or file the xml using XSL. THank you. jollymj23 Sample.xsl Sample.xml ITEM DESC ITEM1 DESC1 ORDER DESC
If I've got your sample correct:
<root>
<child>
<node>
<childnode>ITEM</childnode>
<childnode>DESC</childnode>
</node>
<node>
<childnode>ITEM1</childnode>
<childnode>DESC1</childnode>
</node>
</child>
<child>
<node>
<childnode>ORDER</childnode>
<childnode>DESC</childnode>
</node>
</child>
</root>You can use XPath to filter the result:
<xsl:for-each select="//node[starts-with(string(childnode),'ITEM')]">
<xsl:value-of select="position()"/>
xsl:text </xsl:text>
</xsl:for-each>This should print out
1 2
as it will select the first twonode
elements.