i have a source xml, where i would like to select based on path i.e. from 2nd or 3rd xml node. I have tried with the Some XSLT code, but not getting exact output.
Input XML :
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Header xmlns:ns0="http://xyz987.com">
<Main>
<Parent2>
<Parent2>
<?xml version="1.0" encoding="UTF-8"?>
<Child1>
<GChild1>12</GChild1>
<Child2>
<GChild2>12</GChild2>
</Child2>
</Child1>
</Parent2>
</Parent2>
</Main>
</ns0:Header>
target XML:
<?xml version="1.0" encoding="UTF-8"?>
<Child1>
<GChild1>12</GChild1>
<Child2>
<GChild2>12</GChild2>
</Child2>
</Child1>
Tried XSLT Code :
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:apply-templates select="/Header/Parent2/Parent2"/>
</xsl:template>
<xsl:template match="@*">
<xsl:copy>
<xsl:apply-templates select="@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:element>
</xsl:template>
</xsl:transform>
<?xml version="1.0" encoding="UTF-8"?>declaration in the middle of an XML document. It must only occur on the very first line. Or perhaps in your real XML it is wrapped in a CDATA section, which would make this a very different problem! Thanks!Headerelement is in a namespace, whereas your stylesheet is looking forHeaderelements in no namespace.,