Question : reading xml from a string instead of xml file

I have the following code which reads in some xml and using an xslt file to set the layout it then creates the html page:
Dim resolver As New XmlUrlResolver
        Dim xsltrans As New XslCompiledTransform

        resolver.Credentials = System.Net.CredentialCache.DefaultCredentials

        xsltrans.Load("C:\DespatchNotePrinting\NextDespatch.xslt", Nothing, resolver)

        xsltrans.Transform("C:\DespatchNotePrinting\Test.xml", "C:\DespatchNotePrinting\Results.html") ', resolver)


This works fine.

However rather than read the xml from the file I would just like to use a string that contains the xml.

Say strXML.

Is this possible and if so how?

Answer : reading xml from a string instead of xml file

Try this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
        Dim resolver As New XmlUrlResolver
        Dim xsltrans As New XslCompiledTransform
        Dim oXml As New XmlDocument
        Dim oWriter As XmlWriter
        Dim strXML As String = "Your XML string here"
        Dim strWriter As String = "C:\DespatchNotePrinting\Results.html"

        oXml.LoadXml(strXML)
        oWriter = XmlWriter.Create(strWriter)
        resolver.Credentials = System.Net.CredentialCache.DefaultCredentials

        xsltrans.Load("C:\DespatchNotePrinting\NextDespatch.xslt", Nothing, resolver)

        xsltrans.Transform(oXml, oWriter) ', resolver)
Random Solutions  
 
programming4us programming4us