Export (0) Print
Expand All

XProcessingInstruction.Data Property

Gets or sets the string value of this processing instruction.

Namespace:  System.Xml.Linq
Assemblies:   System.Xml.XDocument (in System.Xml.XDocument.dll)
  System.Xml.Linq (in System.Xml.Linq.dll)

public string Data { get; set; }

Property Value

Type: System.String
A String that contains the string value of this processing instruction.

ExceptionCondition
ArgumentNullException

The string value is null.

You can use this property to modify an XML tree. This property will cause events to occur.

The following example uses the Data property to retrieve the string value of a processing instruction.

XProcessingInstruction pi =
    new XProcessingInstruction("xml-stylesheet", "type='text/xsl' href='hello.xsl'");
Console.WriteLine(pi.Data);
pi.Data = "type='text/xsl' href='xform.xsl'";
Console.WriteLine(pi.Data);

This example produces the following output:

type='text/xsl' href='hello.xsl'
type='text/xsl' href='xform.xsl'

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft