target Property

MSXML 5.0 SDK

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

target Property

Specifies the target for the processing instruction.

[Script]

Script Syntax

strValue = oXMLDOMProcessingInstruction.target;

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 target.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0");
var pi;
xmlDoc.async = false;
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.target);
      }
   }
}
[Visual Basic]

Visual Basic Syntax

strValue = oXMLDOMProcessingInstruction.target

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 target.

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.Target
      End If
   Next
[C/C++]

C/C++ Syntax

HRESULT get_target(
    BSTR *name);

Parameters

name [out, retval]
The application to which this processing instruction is directed (the target).

C/C++ Return Values

S_OK
The value returned if successful.

Remarks

String. The property is read-only. XML defines the target as the first token following the markup that begins the processing instruction. For example, the target has the value "xml" in the processing instruction <?xml version="1.0">.

The target property has the same value as the nodeName 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

nodeName Property

Applies to: IXMLDOMProcessingInstruction