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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get just current node - but not children 1

Status
Not open for further replies.

innmedia

Programmer
Mar 24, 2000
108
US
Hi all,

Does anyone know the XPATH syntax to return just the child one level in, but not all the descendents. For this XML:

<Budget>
<Department>Legal<Variance>12</Variance></Department>
<Department>Sales<Variance>16</Variance></Department>
<Department>Accounting<Variance>1</Variance></Department>
</Budget>

I want to getjust the department names, not department AND variance. Here is the XPATH so far...


<xsl:for-each select=&quot;//Budget/Department&quot;>
<TR>
<TD ALIGN=&quot;Center&quot;><xsl:value-of select=&quot;.&quot;/></TD>
<TD ALIGN=&quot;Center&quot;><xsl:value-of select=&quot;./Variance&quot;/></TD>
</TR>
</xsl:for-each>

This fills two table columns. The second column (for Variance) correctly returns just the number (i.e. 12). But the first column returns the Department and Variance (i.e. Legal 12)

How can I isolate just the Department name to appear in the first column?


Thanks,

Ken B

 
<xsl:value-of select=&quot;text() |* [not(self::Variance)]&quot;/>
 
mulligh -

Thanks! Exactly what I needed. Works perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top