Solved

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

Posted on 2006-06-22
3
139 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

688 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