ProcessingInstruction.target

The read-only target property of the ProcessingInstruction interface represent the application to which the ProcessingInstruction is targeted.

For example:

<?xml version="1.0"?>

is a processing instruction whose targetis xml.

Value

A String containing the name of the application.

Example

In an XML document

let parser = new DOMParser();
const doc = parser.parseFromString('<?xml version="1.0"?><test/>', "application/xml");
const pi = doc.createProcessingInstruction('xml-stylesheet', 'href="mycss.css" type="text/css"');
doc.insertBefore(pi, doc.firstChild);

const output = document.getElementsByTagName("output")[0];
output.textContent = "This processing instruction's target is: " + doc.firstChild.target;

In an HTML document

The processing instruction line will be considered, and represented, as a Comment object.

<?xml version="1.0"?>
<pre></pre>
let node = document.getElementsByTagName("pre")[0].previousSibling.previousSibling;

let result = "Node with the processing instruction: " + node.nodeName + ": " + node.nodeValue + "\n";

document.getElementsByTagName("pre")[0].textContent = result;

Specifications

Specification
DOM Standard
# dom-processinginstruction-target

Browser compatibility

BCD tables only load in the browser

See also