DOM Entity对象notationName
属性给出未解析实体的符号和值的名称。 对于已解析的实体,其值为null
。
语法
以下是使用notationName
属性的语法。
entity.nodeName
示例
文件:notation.xml 的内容如下 -
<?xml version="1.0"?>
<!DOCTYPE address [
<!ELEMENT address (#PCDATA)>
<!NOTATION name PUBLIC "yiibai">
<!ATTLIST address category NOTATION (name) #REQUIRED>
]>
<address name = "yiibai">Haikou Xindazhou</address>
以下示例演示了notationName
属性的用法 -
<!DOCTYPE html>
<html>
<meta charset="utf-8"/>
<head>
<script>
function loadXMLDoc(filename) {
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
} else // code for IE5 and IE6
{
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",filename,false);
xhttp.send();
return xhttp.responseXML;
}
</script>
</head>
<body>
<script>
xmlDoc = loadXMLDoc("/notation.xml");
x = xmlDoc.getElementsByTagName('address');
document.write("属性标记的名称是 : ")
document.write(x.item(0).attributes[0].nodeName);
document.write("<br>")
document.write("属性标记的值是 : ");
document.write(x.item(0).attributes[0].nodeValue);
</script>
</body>
</html>
执行上面示例代码,得到以下结果 -