data Property (IXMLDOMProcessingInstruction)

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - DOM Reference

data Property (IXMLDOMProcessingInstruction)

Retrieves and sets the content of the processing instruction, excluding the target.

[Script]

Script Syntax

strValue = oXMLDOMProcessingInstruction.data;
objXMLDOMProcessingInstruction.data = strValue;

Example

The following script example iterates through the document's child nodes. If it finds a node of type NODE_PROCESSING_INSTRUCTION (7), it displays the node's data.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0");
var pi;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   alert("You have error " + myErr.reason);
} else {
   for (var i=0; i<xmlDoc.childNodes.length; i++) {
      if (xmlDoc.childNodes.item(i).nodeType == 7) {
         pi = xmlDoc.childNodes.item(i);
         alert(pi.data);
      }
   }
}
[Visual Basic]

Visual Basic Syntax

strValue = oXMLDOMProcessingInstruction.data
objXMLDOMProcessingInstruction.data = strValue

Example

The following Microsoft® Visual Basic® example iterates through the document's child nodes. If it finds a node of type NODE_PROCESSING_INSTRUCTION (7), it displays the node's data.

Dim xmlDoc As New Msxml2.DOMDocument50
Dim pi As IXMLDOMProcessingInstruction
xmlDoc.Load ("books.xml")
If (xmlDoc.parseError.errorCode <> 0) Then
   Dim myErr
   Set myErr = xmlDoc.parseError
   MsgBox("You have error " & myErr.reason)
Else
   For i = 0 To (xmlDoc.childNodes.length - 1)
      If xmlDoc.childNodes.Item(i).nodeType = _
      NODE_PROCESSING_INSTRUCTION Then
         Set pi = xmlDoc.childNodes.Item(i)
         MsgBox pi.Data
      End If
   Next
End If
[C/C++]

C/C++ Syntax

HRESULT get_data(
    BSTR *value);
HRESULT put_data(
    BSTR value);

Parameters

value [out, retval][in]
The content of the processing instruction for this target. The data has the same value as the nodeValue property.

C/C++ Return Values

S_OK
The value returned if successful.

Remarks

String. This property is read/write. The data has the same value as the nodeValue property.

To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

nodeValue Property

Applies to: IXMLDOMProcessingInstruction