Add the processing instruction in CSharp
Description
The following code shows how to add the processing instruction.
Example
using System;//from w ww.j av a 2s. c o m
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.IO;
public class MainClass{
public static void Main(string[] args){
XDocument NewDoc = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XElement("Root", "MyDoc"));
// Add the processing instruction.
NewDoc.AddFirst(new XProcessingInstruction(
"xml-stylesheet",
"type='text/xsl' href='MyXSL.XSL'"));
Console.WriteLine(NewDoc);
}
}