Extract a subset of XML file using XSL

Posted by Lucas -luky- Noleto on Stack Overflow See other posts from Stack Overflow or by Lucas -luky- Noleto
Published on 2009-02-25T16:01:18Z Indexed on 2010/05/08 19:08 UTC
Read the original article Hit count: 627

Filed under:
|
|
|
|

I have this XML file:

<Response>
    <errorCode>error Code</errorCode>
    <errorMessage>msg</errorMessage>
    <ResponseParameters>
    	<className>
    		<attribute1>a</attribute1>
    		<attribute2>b</attribute2>
    	</className>
    </ResponseParameters>
</Response>

And I want the output to be:

<className>
    <attribute1>a</attribute1>
    <attribute2>b</attribute2>
</className>

My current XSL file is including also "ResponseParameters" tag, which I do not want.

EDIT: note that the node className is dynamic. I do not know what will be this name at runtime.

<?xml version="1.0"?>

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

    <xsl:output indent="yes" />

    <xsl:template match="/">
    	<xsl:copy-of select="//ResponseParameters">
    	</xsl:copy-of>
    </xsl:template>
</xsl:stylesheet>

© Stack Overflow or respective owner

Related posts about xsd

Related posts about xsl