MSDN Documentation

Search | About

XProcessingInstruction Class

Namespace: System.Xml.Linq

Assembly: System.Xml.Linq (in System.Xml.Linq.dll)

Summary

Represents an XML processing instruction. A processing instruction can be used to embed application-specific data in an XML document.

Syntax

public sealed class XProcessingInstruction : XNode

Constructors

SignatureDescription
XProcessingInstruction(string target)Initializes a new instance with the specified target.
XProcessingInstruction(string target, string data)Initializes a new instance with the specified target and data.

Properties

NameTypeDescription
DatastringGets or sets the content of the processing instruction.
TargetstringGets the target of the processing instruction.
NodeTypeXmlNodeTypeAlways returns XmlNodeType.ProcessingInstruction.

Methods

SignatureDescription
string ToString(SaveOptions options)Returns the XML representation of the node using the specified options.
void WriteTo(XmlWriter writer)Writes the node to an XmlWriter.
void AddAfterSelf(params object[] content)Adds content after this node.
void AddBeforeSelf(params object[] content)Adds content before this node.

Example

Creating a processing instruction and adding it to an XDocument:


XDocument doc = new XDocument(
    new XProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"style.xsl\""),
    new XElement("root",
        new XElement("child", "Content")
    )
);
Console.WriteLine(doc);
        

Remarks

The Target property identifies the application to which the processing instruction applies. The Data property contains the instruction's content.

Show/Hide Additional Notes