- XML DOM Basics
- XML DOM - Home
- XML DOM - Overview
- XML DOM - Model
- XML DOM - Nodes
- XML DOM - Node Tree
- XML DOM - Methods
- XML DOM - Loading
- XML DOM - Traversing
- XML DOM - Navigation
- XML DOM - Accessing
- XML DOM Operations
- XML DOM - Get Node
- XML DOM - Set Node
- XML DOM - Create Node
- XML DOM - Add Node
- XML DOM - Replace Node
- XML DOM - Remove Node
- XML DOM - Clone Node
- XML DOM Objects
- DOM - Node Object
- DOM - NodeList Object
- DOM - NamedNodeMap Object
- DOM - DOMImplementation
- DOM - DocumentType Object
- DOM - ProcessingInstruction
- DOM - Entity Object
- DOM - EntityReference Object
- DOM - Notation Object
- DOM - Element Object
- DOM - Attribute Object
- DOM - CDATASection Object
- DOM - Comment Object
- DOM - XMLHttpRequest Object
- DOM - DOMException Object
- XML DOM Useful Resources
- XML DOM - Quick Guide
- XML DOM - Useful Resources
- XML DOM - Discussion
DOM - ProcessingInstruction Object Attribute - target
The attribute target identifies the application to which the instruction or data is directed.
Syntax
Following is the syntax for the usage of the target attribute.
ProcessingInstruction.target
S.No. | Parameter & Description |
---|---|
1 | target Identifies the application to which the instruction or data is directed. |
Example
Following example demonstrates the usage of the target attribute −
<!DOCTYPE html> <html> <head> <script> // loads the xml string in a dom object function loadXMLString(t) { // for non IE browsers if (window.DOMParser) { // create an instance for xml dom object parser = new DOMParser(); xmlDoc = parser.parseFromString(t,"text/xml"); } else // code for IE { // create an instance for xml dom object xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = false; xmlDoc.loadXML(t); } return xmlDoc; } function get_firstChild(p) { a = p.firstChild; return a; } </script> </head> <body> <script> var xml = "<Employee>"; xml = xml+"<FirstName>"; xml = xml+"<?piTarget piData more piData?>"; xml = xml+"</FirstName>"; xml = xml+"</Employee>"; // calls the loadXMLString() with "text" function and store the xml dom in a variable var xmlDoc = loadXMLString(xml); var x = get_firstChild(xmlDoc.getElementsByTagName("FirstName")[0]); document.write("First child is : "); document.write(x.nodeName); //the following should be "piData more piData" alert(x.data); //the following should be "piTarget" alert(x.target); </script> </body> </html>
Execution
Save this file as dom_processinginstruction_target.htm on the server path. We will get the output as shown below −
dom_processinginstruction_object.htm
Advertisements