How to transform an XML document into another XML document?

Submitted by: Administrator
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>
Submitted by: Administrator

Read Online XSLT Job Interview Questions And Answers