Expected outPut:
<?xml version="1.0" encoding="utf-8"?>
http://www.w3.org/2001/XMLSchema-instance" xmlns="SampleXML">
<Tablix1>
<SIDCode_Collection>
<SIDCode SIDCode="854-2013-17011949">
<PName_Collection>
<PName PName="Test1" />
<PName PName="Test2" />
</PName_Collection>
</SIDCode>
<SIDCode SIDCode="854-2013-17011950">
<PName_Collection>
<PName PName="Test3" />
<PName PName="Test4" />
</PName_Collection>
</SIDCode>
</SIDCode_Collection>
</Tablix1>
I have written the XSLT code to get the above output. But I am not able to get the output as expected. Can some one please help me to find the issue ?
Currently this is giving only SIDCode. But it is not giving the respective Pname results in the XML output.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="SampleXML">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
<xsl:template match="/">
<xsl:for-each select="a:Report/a:Tablix1/a:SIDCode_Collection/a:SIDCode">
<xsl:element name="{name(.)}">
<xsl:for-each select="@SIDCode">
<xsl:element name="{name(.)}">
<xsl:value-of select="."/>
<xsl:for-each select="a:PName_Collection/a:PName">
<xsl:element name="{name(.)}">
<xsl:for-each select="@PName">
<xsl:element name="{name(.)}">
<xsl:value-of select="@PName"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Thank you
Sri