Hard code the xsl and do the transform
Imports System
Imports System.Xml
Imports System.Xml.Xsl
Imports System.Xml.Schema
Imports System.Linq
Imports System.Collections
Imports System.Collections.Generic
Class MainClass
Shared Sub Main()
Dim xslMarkup As XDocument = _
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
<xsl:template match='/Parent'>
<Root>
<C1>
<xsl:value-of select='Child1'/>
</C1>
<C2>
<xsl:value-of select='Child2'/>
</C2>
</Root>
</xsl:template>
</xsl:stylesheet>
Dim xmlTree As XElement = _
<Parent>
<Child1>Child1 data</Child1>
<Child2>Child2 data</Child2>
</Parent>
Dim newTree As XDocument = New XDocument()
Using writer As XmlWriter = newTree.CreateWriter()
Dim xslt As XslCompiledTransform = _
New XslCompiledTransform()
xslt.Load(xslMarkup.CreateReader())
xslt.Transform(xmlTree.CreateReader(), writer)
End Using
Console.WriteLine(newTree)
End Sub
End Class
Related examples in the same category