Ben van Middelkoop
Ben van Middelkoop

Reputation: 11

How to select an element with CDATA without child elements

In an XML file I have an element <WPG> containing A lot of text, including a child with some more text.

<WPG><![CDATA[A lot of text]]>
  <WPL>
    <ADD><profile ref="994042" />
      <Rem><![CDATA[Some more text]]></Rem>
    </ADD>
  </WPL>
</WPG>

When I use

<xsl:value-of select="WPG"/>

I get A lot of text including Some more text.

How can I get only A lot of text without Some more text without changing the XML files itself?

Upvotes: 1

Views: 193

Answers (1)

michael.hor257k
michael.hor257k

Reputation: 117043

<xsl:value-of select="WPG/text()"/>

will work for your example - not sure if it's general enough to cover all your cases, though.

Upvotes: 3

Related Questions