This page contains the XML for <SCRIPT> DOMProcessingInstruction object documentation.
Return to W3C DOM Parser Documentation Main Page
NOTE: DOMProcessingInstruction descends from
DOMNode and inherits
all of the properties and methods of the DOMNode object
-
CONTENTS
-
DOMProcessingInstruction - object description
-
-
-
Native Methods:
-
DOMProcessingInstruction - getTarget method
-
DOMProcessingInstruction - getData method
-
DOMProcessingInstruction - setData method
-
-
-
Inherited Methods:
-
DOMNode - getNodeName method
-
DOMNode - getNodeValue method
-
DOMNode - setNodeValue method
-
DOMNode - getNodeType method
-
DOMNode - getParentNode method
-
DOMNode - getChildNodes method
-
DOMNode - getFirstChild method
-
DOMNode - getLastChild method
-
DOMNode - getPreviousSibling method
-
DOMNode - getNextSibling method
-
DOMNode - getAttributes method
-
DOMNode - getNamespaceURI method
-
DOMNode - getPrefix method
-
DOMNode - getLocalName method
-
DOMNode - getOwnerDocument method
-
DOMNode - insertBefore method
-
DOMNode - replaceChild method
-
DOMNode - removeChild method
-
DOMNode - appendChild method
-
DOMNode - hasChildNodes method
-
DOMNode - cloneNode method
-
DOMNode - getElementsByTagName method
-
DOMNode - getElementsByTagNameNS method
-
DOMNode - setPrefix method
-
DOMNode - normalize method
-
DOMNode - isSupported method
-
DOMNode - getXML method
-
DOMNode - hasAttributes method
DOMProcessingInstruction - object description
The DOMProcessingInstruction interface represents a "processing instruction",
used in XML as a way to keep processor-specific information in the text
of the document.
DOMProcessingInstruction - getTarget method
W3C DOM Level 1
DOMProcessingInstruction.getTarget()
accepts:
N/A
returns:
String - the target of the processing instruction
throws:
N/A
The getTarget method returns the target of the DOMProcessingInstruction. The target
of a processing instruction is the part of the tag directly after the first question
mark. For example, in the processing instruction
<?piTarget piData?>
the target is "piTarget".
NOTE: Although XML for <SCRIPT> does not
parse processing instructions, it fully supports their creation, reading, and
manipulation.
Example:
function xmljsDOMExample() {
var xml;
xml = ""
+ "<?xml version=\"1.0\"?>"
+ "<ROOTNODE>"
+ "<TAG1 foo=\"goo\" id=\"tag1_id\">"
+ "<?piTarget piData?>"
+ "</TAG1>"
+ "</ROOTNODE>";
//instantiate the W3C DOM Parser
var parser = new DOMImplementation();
//load the XML into the parser and get the DOMDocument
var domDoc = parser.loadXML(xml);
//get the root node
var docRoot = domDoc.getDocumentElement();
//find tag1 by searching by its id
var tag1 = domDoc.getElementById("tag1_id");
//get a DOMNamedNodeMap of the attributes for tag1
var namedNodeMap = tag1.getAttributes();
//get the processing instruction in tag1
var pi = tag1.getFirstChild();
//the following should be "piTarget"
alert(pi.getTarget());
}// end function xmljsDOMExample
DOMProcessingInstruction - getData method
W3C DOM Level 1
DOMProcessingInstruction.getData()
accepts:
N/A
returns:
String - the data of the processing instruction
throws:
N/A
The getData method returns the data of the DOMProcessingInstruction. The data
of a processing instruction is the part of the tag after the first space in the
processing instruction. For example, in the processing instruction
<?piTarget piData more piData?>
the data is "piData more piData".
NOTE: Although XML for <SCRIPT> does not
parse processing instructions, it fully supports their creation, reading, and
manipulation.
Example:
function xmljsDOMExample() {
var xml;
xml = ""
+ "<?xml version=\"1.0\"?>"
+ "<ROOTNODE>"
+ "<TAG1 foo=\"goo\" id=\"tag1_id\">"
+ "<?piTarget piData more piData?>"
+ "</TAG1>"
+ "</ROOTNODE>";
//instantiate the W3C DOM Parser
var parser = new DOMImplementation();
//load the XML into the parser and get the DOMDocument
var domDoc = parser.loadXML(xml);
//get the root node
var docRoot = domDoc.getDocumentElement();
//find tag1 by searching by its id
var tag1 = domDoc.getElementById("tag1_id");
//get a DOMNamedNodeMap of the attributes for tag1
var namedNodeMap = tag1.getAttributes();
//get the processing instruction in tag1
var pi = tag1.getFirstChild();
//the following should be "piData more piData"
alert(pi.getData());
}// end function xmljsDOMExample
DOMProcessingInstruction - setData method
W3C DOM Level 1
DOMProcessingInstruction.setData(<newData>)
accepts:
String newData - the new data for the DOMProcessingInstruction
returns:
N/A
throws:
The setData method sets the data of the DOMProcessingInstruction. The data
of a processing instruction is the part of the tag after the first space in the
processing instruction. For example, in the processing instruction
<?piTarget piData more piData?>
the data is "piData more piData".
NOTE: Although XML for <SCRIPT> does not
parse processing instructions, it fully supports their creation, reading, and
manipulation.
Example:
function xmljsDOMExample() {
var xml;
xml = ""
+ "<?xml version=\"1.0\"?>"
+ "<ROOTNODE>"
+ "<TAG1 foo=\"goo\" id=\"tag1_id\">"
+ "<?piTarget piData more piData?>"
+ "</TAG1>"
+ "</ROOTNODE>";
//instantiate the W3C DOM Parser
var parser = new DOMImplementation();
//load the XML into the parser and get the DOMDocument
var domDoc = parser.loadXML(xml);
//get the root node
var docRoot = domDoc.getDocumentElement();
//find tag1 by searching by its id
var tag1 = domDoc.getElementById("tag1_id");
//get a DOMNamedNodeMap of the attributes for tag1
var namedNodeMap = tag1.getAttributes();
//get the processing instruction in tag1
var pi = tag1.getFirstChild();
//set the processing instruction's data to "newPiData"
pi.setData("newPiData")
//the following should be "newPiData"
alert(pi.getData());
}// end function xmljsDOMExample