このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

ProcessingInstruction: target プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年7月⁩.

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

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

html
<?xml version="1.0"?> 

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

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

XML 文書内で

js
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.querySelector("output"); output.textContent = `この処理命令のターゲット: ${doc.firstChild.target}`; 

HTML 文書内で

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

html
<?xml version="1.0"?> <pre></pre> 
js
const node = document.querySelector("pre").previousSibling.previousSibling; const result = `この処理命令のノード: ${node.nodeName}: ${node.nodeValue}\n`; document.querySelector("pre").textContent = result; 

仕様書

Specification
DOM
# dom-processinginstruction-target

ブラウザーの互換性

関連情報