0

How do I select nodes without including any child nodes in my select?

For example:

 <Result>a
  <subresult>1
  </subresult>
 </Result>

From the above code when I select the result node I get the following output:

a1

I am interested in the following output:

a

user2411083
  • 29
  • 1
  • 4

1 Answers1

0

The a is part of a text child node of the Result element so if you want the a but not the 1 then you want the text child nodes but not any descendant text nodes. As the question is tagged as XSLT 2.0, you should be able to use <xsl:value-of select="/Result/text()" separator=""/>. With an XSLT 2.0 processor and version="2.0" this will output the string values of all text child nodes, thus if there is e.g. <Result>a<subresult>1</subresult>b</Result> you would get ab.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110