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!

Extract Node Text using XSL 1

Status
Not open for further replies.

Dachyon

Programmer
Nov 4, 2002
32
NZ
Hi, need some help with this :-
I have some XML...

<TRANSPORT>Bicycle
<RANGE SELECTED=&quot;4&quot;>
<_0>Walk</_0>
<_1>Car</_1>
<_2>MotorCycle</_2>
<_3>Aeroplane</_3>
<_4>Bicycle</_4>
</RANGE>
</TRANSPORT>

I want to extract the value of the Text Node of the transport element using XSL.

<xsl:value-of select=&quot;TRANSPORT&quot;/>

yields :-

Bicycle WalkCarMotorcycleAeroplaneBicycle

but all I want is Bicycle
Does anyone have any suggestions.

Many Tnx.
Dachyon
 
This may be difficult, as this isn't correct XML. You're not allowed to have a value under a node, plus other elements. You might have to do it via text-parsing.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Dachyon,

Try this:
Code:
<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform&quot;>[/URL]
  <xsl:template match=&quot;/TRANSPORT&quot;>
    <xsl:value-of select=&quot;text()&quot;/>
  </xsl:template>
</xsl:stylesheet>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top