Solved

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

Posted on 2006-06-22
3
132 Views
Last Modified: 2010-04-30
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")
0
Comment
Question by:JasonWinn
  • 2
3 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16962099
Not quite sure what you mean. Do you want to programmatically add:

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

?
0
 
LVL 3

Author Comment

by:JasonWinn
ID: 16962102
yep :)
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 16962183
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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now