Parsing XML using XSLT?

dorahedgehog

New Member
How can I parse a XML document using XSLT? May be I am wrong, Is it possible to parse a XML document using XSLT?Here is XML document:\[code\]<?xml version="1.0" encoding="utf-8" ?><cart> <item id="1"> <name>Tyres</name> <cost>20</cost> </item> <item id="2"> <name>Front Glass</name> <cost>30</cost> </item> <item id="3"> <name>Vanity Mirror</name> <cost>10</cost> </item> <item id="4"> <name>Brake Pads</name> <cost>50</cost> </item> <item id="5"> <name>Brake Oil</name> <cost>40</cost> </item></cart>\[/code\]and the XSLT page:\[code\]<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> <xsl:output method="xml" indent="yes"/> <xsl:template match="shopping_cart"> <root> <xsl:apply-templates select="cart"/> </root> </xsl:template> <xsl:template match="cart"> <cart> <xsl:attribute name="name"> <xsl:value-of select="name"/> </xsl:attribute> <xsl:attribute name="cost"> <xsl:value-of select="cost"/> </xsl:attribute> </cart> </xsl:template></xsl:stylesheet>\[/code\]Any way to do that? Please guide as I don't know much about parsing concept.
 
Back
Top