Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - XML XSLT Table display [Thread Next] Re: XML XSLT Table displayTo: NULL Date: 1/7/2008 10:47:00 AM Pradeep wrote: > I have a following XML file > <ITEMLIST> > <ITEM> > <NAME> Item1 </ITEM> > <PRICE> 500 </PRICE> > </ITEM> > <ITEM> > <NAME> Item2 </ITEM> > <PRICE> 600 </PRICE> > <LOCATION> XYZ</LOCATION> > </ITEM> > <ITEM> > <NAME> Item3 </ITEM> > <PRICE> 700 </PRICE> > <QTY> 25 </QTY> > </ITEM> > <ITEM> > <NAME> Item4 </ITEM> > <PRICE> 900 </PRICE> > <QTY> 90 </QTY> > </ITEM> > </ITEMLIST> > > and want to display in HTML like following > > ------------------------------------------- > | | PRICE | LOCATION | QTY | > ------------------------------------------- > Item1 | 500 | | | > ------------------------------------------- > Item1 | 600 | XYZ | | > ------------------------------------------- > Item1 | 700 | | 25 | > ------------------------------------------- > Item1 | 900 | | 90 | > ------------------------------------------- > > > Is it possible via XSLT to do this ...If yes, kindly provide a small > code snippet to do this That's pretty much trivial: <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="ITEMLIST"> <table> <tr> <th>Name</th> <th>Price</th> <th>Location</th> <th>Qty</th> </tr> <xsl:apply-templates/> </table> </xsl:template> <xsl:template match ="ITEM"> <tr> <td> <xsl:value-of select="NAME" /> </td> <td> <xsl:value-of select="PRICE" /> </td> <td> <xsl:value-of select="LOCATION" /> </td> <td> <xsl:value-of select="QTY" /> </td> </tr> </xsl:template> </xsl:stylesheet> -- Oleg http://www.tkachenko.com/blog | http://www.XmlLab.Net | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
