ProcessingInstruction Object
Last Updated: 08-26-2005
Represents an XML processing instruction in the Document Object Model (DOM).

The ProcessingInstruction object is a specialized node object in an XML document that contains a processing instruction.
Prior to revision 3, processing instruction nodes are not accessible via the DOM. In revision 3 and later, they are accessible.

Consider the following sample XML document that includes several processing instructions:

<?xml version="1.0"?>
<?access-control allow="*"?>
<?Magnum is a type of gun?>
<?PI "is the ratio of the circumference of a circle to its diameter"?>
<?Magnum P.I. was an '80s TV show?>
    Document stuff goes here...

Here is a program that could be used to process the XML document. It traverses the document to determine the number of processing instruction nodes and to gather their content. Finally, it states the number of processing instruction nodes and enumerates them, reporting for each the type of processing instruction it is ( and its content (

<vxml version="2.1"

   <data name="dom" src="pisample.xml"/>

   var aValues = [];
   try {
      for (var i = 0; i < dom.childNodes.length; i++)
         var oNode = dom.childNodes.item(i);
         if (oNode.nodeType == Node.PROCESSING_INSTRUCTION_NODE)
            aValues.push({'target' :, 'data' :});
   { vxmllog("Exception: " + e); }

         <prompt>The document has <value expr="aValues.length"/> 
            processing instruction nodes.</prompt>
         <break size="small"/>
         <var name="j" expr="0"/>
         <foreach item="oValue" array="aValues">
            <assign name="j" expr="j+1"/>
            <prompt>Number <value expr="j"/></prompt>
            <break size="small"/>
            <prompt><value expr=""/></prompt>
            <prompt><value expr=""/></prompt>
            <break size="small"/>

[24]7 Inc.| Terms of Service| Privacy Policy| General Disclaimers