共用方式為


XProcessingInstruction.Data 屬性

定義

取得或設定此處理指令的字串值。

public:
 property System::String ^ Data { System::String ^ get(); void set(System::String ^ value); };
public string Data { get; set; }
member this.Data : string with get, set
Public Property Data As String

屬性值

此處理指令的字串值。

例外狀況

字串 valuenull

範例

以下範例利用該 Data 特性來取得處理指令的字串值。

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);
Dim pi As 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)

此範例會產生下列輸出:

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

備註

你可以利用這個屬性來修改 XML 樹。 這個屬性會引發事件發生。

適用於

另請參閱