Error at converting XML to String

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am trying to convert an XmlDocument to string so I can use in my transformation, but I get Illegal characters in path. exception.Dim loadedXmlDoc As New XmlDocument()
load the xml string taken from the database
loadedXmlDoc.Load("C:UsersmyXmlFile.xml")
Dim stringifiedXmlDoc As String = loadedXmlDoc.OuterXml
Dim stringifiedXmlDoc As String = loadedXmlDoc.InnerText
Dim sw As New StringWriter()
Dim xw As New XmlTextWriter(sw)
loadedXmlDoc.WriteTo(xw)
Dim stringifiedXmlDoc As String = sw.ToString()

load the stylesheet
xslt.Load(xr)
xslt.Transform(stringifiedXmlDoc, "C:UsersgkDesktopnewXTilbud.xml")
So, you see I tried 3 different ways of converting the XML document to string and everytime I get the same exception. On the other hand, when I put the XMl file directly into the .Transform() method, it works completely fine. Like this:
[background=transparent]xslt[/background][background=transparent].[/background][background=transparent]Transform[/background][background=transparent]([/background][background=transparent]"C:UsersmyXmlFile.xml"[/background][background=transparent],[/background][background=transparent] [/background][background=transparent]"C:UsersnewXmlFile.xml"[/background][background=transparent])[/background]
But I need it to be as a string object, because I am actually acquiring the XML from a database as string. This here is just test class. So in the main program I cannot load the XML document directly from the physical file into the .Transform() method.

I tested saving the stringifiedXmlDoc to another XML document, to check for some syntax mistakes, but it is completely the same, as the original one.


View the full article
 

Similar threads

Back
Top