<?xml version="1.0" encoding="ISO-8859-1"?> <Inventory> <Line> <ItemNumber>line</ItemNumber> <Description>desc</Description> <Quantity>quan</Quantity> <Date>date</Date> </Line> <Line> <ItemNumber>1</ItemNumber> <Description>Oak chairs</Description> <Quantity>6</Quantity> <Date>31 Dec 2004</Date> </Line> <Line> <ItemNumber>2</ItemNumber> <Description>Dining tables</Description> <Quantity>1</Quantity> <Date>31 Dec 2004</Date> </Line> <Line> <ItemNumber>3</ItemNumber> <Description>Folding chairs</Description> <Quantity>4</Quantity> <Date>29 Dec 2004</Date> </Line> <Line> <ItemNumber>4</ItemNumber> <Description>Couch</Description> <Quantity>1</Quantity> <Date>31 Dec 2004</Date> </Line> <Line> <ItemNumber>5</ItemNumber> <Description>Overstuffed chair</Description> <Quantity>1</Quantity> <Date>30 Dec 2004</Date> </Line> <Line> <ItemNumber>6</ItemNumber> <Description>Ottoman</Description> <Quantity>1</Quantity> <Date>31 Dec 2004</Date> </Line> <Line> <ItemNumber>7</ItemNumber> <Description>Floor lamp</Description> <Quantity>1</Quantity> <Date>20 Dec 2004</Date> </Line> <Line> <ItemNumber>8</ItemNumber> <Description>Oak bookshelves</Description> <Quantity>1</Quantity> <Date>31 Dec 2004</Date> </Line> <Line> <ItemNumber>9</ItemNumber> <Description>Computer desk</Description> <Quantity>1</Quantity> <Date>31 Dec 2004</Date> </Line> <Line> <ItemNumber>10</ItemNumber> <Description>Folding tables</Description> <Quantity>3</Quantity> <Date>31 Dec 2004</Date> </Line> <Line> <ItemNumber>11</ItemNumber> <Description>Oak writing desk</Description> <Quantity>1</Quantity> <Date>28 Dec 2004</Date> </Line> <Line> <ItemNumber>12</ItemNumber> <Description>Table lamps</Description> <Quantity>5</Quantity> <Date>26 Dec 2004</Date> </Line> <Line> <ItemNumber>13</ItemNumber> <Description>Pine night tables</Description> <Quantity>3</Quantity> <Date>26 Dec 2004</Date> </Line> <Line> <ItemNumber>14</ItemNumber> <Description>Oak dresser</Description> <Quantity>1</Quantity> <Date>30 Dec 2004</Date> </Line> <Line> <ItemNumber>15</ItemNumber> <Description>Pine dressers</Description> <Quantity>1</Quantity> <Date>31 Dec 2004</Date> </Line> <Line> <ItemNumber>16</ItemNumber> <Description>Pine armoire</Description> <Quantity>1</Quantity> <Date>31 Dec 2004</Date> </Line> </Inventory> C:\Hacks\examples>cat csv.xsl <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="Inventory"> <xsl:apply-templates select="Line"/> </xsl:template> <xsl:template match="Line"> <xsl:for-each select="*"> <xsl:value-of select="."/> <xsl:if test="position() != last()"> <xsl:value-of select="','"/> </xsl:if> </xsl:for-each> <xsl:text> </xsl:text> </xsl:template> </xsl:stylesheet>The process itself is quite simple. Load the XSL stylesheet and perform the transformation:
Dim xslt As New XslTransform() xslt.Load(stylesheetfilename) xslt.Transform(inputfile.xml, outputfile.csv|txt, Nothing)