XSLT (XSL Transformations) Question:

How to transform an XML document into another XML document?

Tweet Share WhatsApp

Answer:

Here,I given you a exampl which show you how to transform an XML document into another XML document.
Example:
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/persons">
<root> <xsl:apply-templates select="person"/> </root>
</xsl:template>
<xsl:template match="person">
<name username="{@username}">
<xsl:value-of select="name" />
</name>
</xsl:template>
</xsl:stylesheet>
We can tranform above XML document into another document like that,
<?xml version="1.0" encoding="UTF-8"?>
<root>
<name username="jhoh">jhon</name>
<name username="smith">smith</name>
</root>

Download XSLT PDF Read All 31 XSLT Questions
Previous QuestionNext Question
How to transform an XML into XHTML?How we compare XSLT and XPath?