Hi,
First you need to create XSL stylesheet. You could save it into the file and
it would look like (someone probably could provide different stylesheet)
Assuming that dataset name is MyDS and table name is Table 1
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="/MyDS">
<xsl:element name="MyNewXML">
<xsl:for-each select="*">
<xsl:element name="Table1">
<xsl:attribute name="Field1"><xsl:value-of
select="Field1"/></xsl:attribute>
<xsl:attribute name="Field2"><xsl:value-of
select="Field2"/></xsl:attribute>
<xsl:attribute name="Field3"><xsl:value-of
select="Field3"/></xsl:attribute>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Now, your VB code would look like
Dim loSourceXML as XPath.xPathDocument
Dim loTransform as Xsl.Xsltransform
Dim loXmlOutput as XmlTextWriter
loSourceXML = new XPath.xPathDocument(New StringBuilder(MyDataSet.GetXml()))
loTransform = New Xsl.Xsltransform()
loTransform.Load("Path to the stylesheet")
loXmlOutput = New XmlTextWriter("Path to the output XML file here",Nothing)
loTransform.Transform(loSourceXML,Nothing,loXmlOutput)
Val Mazur
Microsoft MVP