ProcessingInstruction.target

targetProcessingInstruction インターフェイスの読み取り専用プロパティで、 ProcessingInstruction が対象とするアプリケーションを表します。

例えば次のようなものです。

<?xml version="1.0"?>

この場合、処理命令の targetxml です。

アプリケーションの名前が入った文字列です。

XML 文書内で

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 = "処理命令のターゲット: " + doc.firstChild.target;

HTML 文書内で

処理命令行は Comment オブジェクトと見なされ、表現されます。

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

let result = "処理命令のノード: " + node.nodeName + ": " + node.nodeValue + "\n";

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

仕様書

Specification
DOM Standard
# dom-processinginstruction-target

ブラウザーの互換性

BCD tables only load in the browser

関連情報