Reputation: 3930
I want to get the text from the node <hello>
, excluding its children. I know that /element/hello/text()
is supposed to work, but it doesn't.
<element>
<hello><b>Exclude me</b> but not me <b>I'm excluded :(</b> I'm included</hello>
</element>
My output is only:but not me
. If I remove the first node, everything works as it is supposed and the second text node (I'm included) is parsed. Here, the native processor behaves similarly. Saxon works as expected. Might this be a bug? I'm using XML filters in LibreOffice 4.4.2.2.
Upvotes: 0
Views: 325
Reputation: 117140
I want to get the text from the node
<hello>
, excluding its children. I know that/element/hello/text()
is supposed to work, but it doesn't.
/element/hello/text()
does work to select the nodes you want.
However, if you're using xsl:value-of
to get the text, it will only return the value from the first node of the selected set. To get all of them, you must do:
<xsl:for-each select="/element/hello/text()">
<xsl:value-of select="." />
</xsl:for-each>
The above applies to XSLT 1.0. In XSLT 2.0,
<xsl:value-of select="/element/hello/text()"/>
will return the text of all selected nodes, separated by a space (unless you specify a different separator).
Upvotes: 1