Represents an XML processing instruction. Processing instructions are XML markup that represent instructions for the application handling the XML document, rather than data to be parsed.
class XmlProcessingInstruction : XmlLinkedNode
A processing instruction has a target and data. The target is the application to which the instruction is directed.
The data is the content of the instruction. For example, in the processing instruction
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
, the target is "xml-stylesheet"
and the data is "type="text/xsl" href="style.xsl"".
This class represents the processing instruction node within the XmlDocument object model.
Gets the node type for the current node.
Gets or sets the value of the processing instruction (the data part).
Gets the target of the processing instruction.
Creates a copy of this node.
Saves the current node to the specified XmlWriter.
Creating and writing a processing instruction:
using System;
using System.Xml;
public class Example
{
public static void Main(string[] args)
{
// Create a new XML document
XmlDocument doc = new XmlDocument();
// Create a processing instruction
XmlProcessingInstruction pi = doc.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"style.xsl\"");
// Append the processing instruction to the document
doc.AppendChild(pi);
// Create an XmlWriter to save the document
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
using (XmlWriter writer = XmlWriter.Create(Console.Out, settings))
{
doc.WriteTo(writer);
}
}
}
<?xml-stylesheet type="text/xsl" href="style.xsl"?>