Home | Top | Free Ajax Editor | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.


createProcessingInstruction Method

Creates a processing instruction node that contains the supplied target and data.

[Script]

Script Syntax

var objXMLDOMProcessingInstruction = oXMLDOMDocument.createProcessingInstruction( target , data );

Parameters

target A string specifying the target part of the processing instruction. This supplies the nodeName property of the new object. data A string specifying the rest of the processing instruction preceding the closing ?> characters. This supplies the nodeValue property for the new object.

Return Value

An object. Returns the new IXMLDOMProcessingInstruction object.

Example

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.4.0");
var pi;
xmlDoc.async = false;
xmlDoc.resolveExternals = 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); }
Home | Top | Free Ajax Editor | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.