How To Transform An XML Document Into Another XML Document?
Answers

Question and Answer:

  Home  XSLT

⟩ How to transform an XML document into another XML document?

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>

 206 views

More Questions for you: