How do I add an XSL record to my XML File?

I need to add a record to my XML file that links the XML file to the XSL file i created.. I have the load and save part, but couldnt find anything on how to add an XSL definition to the exsisting XML file.

Thanks!

        Dim xDoc As XmlDocument

        xDoc = New XmlDocument
        xDoc.Load("C:\Documents and Settings\jwinn\My Documents\XML\QBResponse4.xml")


        xDoc.Save("C:\tesing\myData.xml")
LVL 3
JasonWinnAsked:
Who is Participating?
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
Something like the following shoud do the trick:

        Dim doc As New XmlDocument()
        doc.LoadXml("<root><child>Wibble</child></root>")

        doc.InsertBefore(doc.CreateProcessingInstruction("xml-stylesheet", "type=""text/xsl"" href=""mytransform.xsl"""), doc.DocumentElement)

        MessageBox.Show(doc.OuterXml)
0
 
Carl TawnSystems and Integration DeveloperCommented:
Not quite sure what you mean. Do you want to programmatically add:

    <?xml-stylesheet type="text/xsl" href="yourStylesheet.xsl"?>

?
0
 
JasonWinnAuthor Commented:
yep :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.