Hi All,
I have a following xml:

<?xml version="1.0" encoding="UTF-8"?>
<ForwardRequestResponse xmlns:m="http://webservices.kuoni.ch">
	<ForwardRequestResult><![CDATA[<?xml version="1.0" encoding="windows-1252"?><Response Version="2.5" From="KUONEKA0" To="CETS" TermId="XXXXXX" Date="18062009" Time="163523" Type="ERROR" Confirm="X" Agent="XXXXXX" Lang="EN" UserCode="X" UserType="X" UserName="X" UserFirstName="X" Mode="X"><Err><ErrorNr>9999</ErrorNr><ErrorText>Fehlerhafter Request</ErrorText><ErrorText>element &lt;Request&gt; attribute: TermId is too long</ErrorText></Err></Response>]]></ForwardRequestResult>
</ForwardRequestResponse>

And I want to extract a CDATA out of it i.e.

<?xml version="1.0" encoding="windows-1252"?>
<Response Version="2.5" From="KUONEKA0" To="CETS" TermId="XXXXXX" Date="18062009" Time="163523" Type="ERROR" Confirm="X" Agent="XXXXXX" Lang="EN" UserCode="X" UserType="X" UserName="X" UserFirstName="X" Mode="X">
	<Err>
		<ErrorNr>9999</ErrorNr>
		<ErrorText>Fehlerhafter Request</ErrorText>
		<ErrorText>element &lt;Request&gt; attribute: TermId is too long</ErrorText>
	</Err>
</Response>

Could someone please give me some pointers on how to do it?

One way would be to extract the CDATA first

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text" />

<xsl:template match="ForwardRequestResponse">
   <xsl:value-of select="."/>
</xsl:template>

<xsl:template match="/">
    <xsl:apply-templates select="ForwardRequestResponse"/>
</xsl:template>

</xsl:stylesheet>

and then process it though an XML pretty printer such as

<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="xml"/>
   <xsl:param name="indent-increment" select="'   '" />

   <xsl:template match="*">
      <xsl:param name="indent" select="'&#xA;'"/>

      <xsl:value-of select="$indent"/>
      <xsl:copy>
        <xsl:copy-of select="@*" />
        <xsl:apply-templates>
          <xsl:with-param name="indent"
               select="concat($indent, $indent-increment)"/>
        </xsl:apply-templates>
        <xsl:if test="*">
          <xsl:value-of select="$indent"/>
        </xsl:if>
      </xsl:copy>
   </xsl:template>

   <xsl:template match="comment()|processing-instruction()">
      <xsl:copy />
   </xsl:template>

   <!-- WARNING: this is dangerous. Handle with care -->
   <xsl:template match="text()[normalize-space(.)='']"/>

</xsl:stylesheet>

which I found on Dave Pawsons website.

Thanks but i already did it myself. Anyway much appreciated!

hi all,
sorry i am posting on top of this mail
i have a problem
see one xml file look like
<my-app>
<name></name>
<!--<class></class>-->
</my-app>

i want to uncomment the commented part through xslt. please help me

thanks in advance

This article has been dead for over six months. Start a new discussion instead.