Creates a processing instruction node that contains the supplied target and data.
var objXMLDOMProcessingInstruction = oXMLDOMDocument.createProcessingInstruction(target, data);
nodeName property of the new object.nodeValue property for the new object.An object. Returns the new IXMLDOMProcessingInstruction object.
The following script example specifies the target string "xml" and the data string "version=\"1.0\"" to generate the processing instruction <?XML version="1.0"?>.
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 {
pi = xmlDoc.createProcessingInstruction("xml", "version=\"1.0\"");
xmlDoc.insertBefore(pi, xmlDoc.childNodes.item(0));
alert(xmlDoc.xml);
}
Set objXMLDOMProcessingInstruction = oXMLDOMDocument.createProcessingInstruction(target, data)
nodeName property of the new object.nodeValue property for the new object.An object. Returns the new IXMLDOMProcessingInstruction object.
The following Microsoft® Visual Basic® example specifies the target string "xml" and data string "version = \"1.0\"" to generate the processing instruction <?XML version="1.0"?>.
Dim xmlDoc As New Msxml2.DOMDocument50
Dim pi As IXMLDOMProcessingInstruction
xmlDoc.async = False
xmlDoc.Load ("books.xml")
If (xmlDoc.parseError.errorCode <> 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
MsgBox("You have error " & myErr.reason)
Else
Set pi = xmlDoc.createProcessingInstruction("xml", "version=\"1.0\"")
xmlDoc.insertBefore pi, xmlDoc.childNodes.Item(0)
MsgBox (xmlDoc.xml)
End If
HRESULT createProcessingInstruction(
BSTR target,
BSTR data,
IXMLDOMProcessingInstruction **pi);
nodeName property of the new object.nodeValue property for the new object.IXMLDOMProcessingInstruction object.pi parameter is Null.Creating a processing instruction node with this method is the same as using createNode where the Type parameter value is NODE_PROCESSING_INSTRUCTION and no namespace is specified. You cannot specify a namespace with the createProcessingInstruction method.
Although this method creates the new object in the context of this document, it does not automatically add the new object to the document tree. In other words, although the ownerDocument property of the new node points to this document object, the parentNode property is set to Null. To add the new object, you must explicitly call one of the node insert methods, insertBefore method, replaceChild method, or appendChild method.
The new object's nodeType property has the value NODE_PROCESSING_INSTRUCTION.
To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button
in the upper-left corner of the page.
nodeName Property | nodeType Property | nodeValue Property | IXMLDOMProcessingInstruction | createNode Method | ownerDocument Property | insertBefore Method | replaceChild Method | appendChild Method
Applies to: DOMDocument