I am trying to code vb.net to perform XML transformations
by applying a style sheet to a XML doc. All of my XML and
XSLT documents will be in either XML DOM Objects or string
variables. I am not reading anything from Disk.
Prior to .NET, I would this with the following code:
------ ******************* --------
'Load Source cXML into DOM object
Set objSource = server.CreateObject("microsoft.xmldom")
objSource.loadXML(SourceXML)
'Load the Style Sheet
Set objStyle = server.CreateObject("microsoft.xmldom")
objStyle.load(XSLT stylesheet)
'Set up the Output XMLdocument.
Set objSSXML = server.CreateObject("microsoft.xmldom")
' Parse results into a result DOM Document.
call objSource.transformNodeToObject(objStyle, objSSXML)
------ ******************* --------
In .NET, there is no longer a "transformNodeToObject"
method. It doesn't exist. I now have to use
the "XslTransform" object. I have found at least 1/2
dozen different code examples on the MSDN site showing how
you would use the "Transform" method, yet not one example
will compile. For example, here is one sample code
snippet I found:
Imports System
Imports System.IO
Imports System.Xml
Imports System.Xml.XPath
Imports System.Xml.Xsl
Public Class Sample()
Dim xslt as XslTransform = new XslTransform()
Xslt.Load(someStylesheet)
Dim doc as XPathDocument = New XPathDocument("books.xml")
Dim fs as StringWriter = new StringWriter()
Xslt.Transform(doc, Nothing, fs, Nothing);
End Class
As soon as I copy that into my .NET application, the last
line "Xslt.Transform....." gets underlined indicating an
error and if I try to compile I get a "Overload resolution
failed because no accessible 'Transform' accepts this
number of arguments".
Has anyone had any success performing transformations
where all XML data is String data in memory? If so, how
are you doing it? Thanks.