- XML DOM 基礎知識
- XML DOM - 主頁
- XML DOM - 概述
- XML DOM - 模型
- XML DOM - 節點
- XML DOM - 節點樹
- XML DOM - 方法
- XML DOM - 載入
- XML DOM - 遍歷
- XML DOM - 導航
- XML DOM - 訪問
- XML DOM 操作
- XML DOM - 獲取節點
- XML DOM - 設定節點
- XML DOM - 建立節點
- XML DOM - 新增節點
- XML DOM - 替換節點
- XML DOM - 刪除節點
- XML DOM - 克隆節點
- XML DOM 物件
- DOM - 節點物件
- DOM - 節點列表物件
- DOM - 命名節點對映物件
- DOM - DOMImplementation
- DOM - DocumentType 物件
- DOM - 處理指令
- DOM - 實體物件
- DOM - 實體引用物件
- DOM - 符號物件
- DOM - 元素物件
- DOM - 屬性物件
- DOM - CDATASection 物件
- DOM - 註釋物件
- DOM - XMLHttpRequest 物件
- DOM - DOMException 物件
- XML DOM 有用資源
- XML DOM - 快速指南
- XML DOM - 有用資源
- XML DOM - 討論
DOM - 處理指令物件屬性 - data
data 屬性是描述緊接在?>之前的應用程式要處理的資訊的字元。
語法
以下是 data 屬性用法的語法。
ProcessingInstruction.target
| 序號 | 引數和說明 |
|---|---|
| 1 | data 它是描述緊接在?>之前的應用程式要處理的資訊的字元。 |
示例
以下示例演示了 data 屬性的用法:
<!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>
執行
以 dom_processinginstruction_data.htm 的形式將該檔案儲存在伺服器路徑上。我們將獲得如下所示的輸出:
dom_processinginstruction_object.htm
廣告