DOM - DocumentType 对象属性 - notation
属性 notations 包含 DTD 中声明的符号。
示例
notation.xml 内容如下 −
<?xml version = "1.0"?> <!DOCTYPE address [ <!ELEMENT address (#PCDATA)> <!NOTATION name PUBLIC "Tanmay"> <!ATTLIST address category NOTATION (name) #REQUIRED> ]> <address name = "Tanmay">Hello world!!!!!!</address>
以下示例演示了 notations 属性的用法 −
<!DOCTYPE html> <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("/dom/notation.xml"); var notations = xmlDoc.doctype.notations; document.write("notations: "+notations); document.write("Item "+notations.getNamedItem('Tanmay')); </script> </body> </html>
执行
将此文件保存为服务器路径上的 documenttype_notations.html(此文件和 notation.xml 应位于服务器中的同一路径上)。我们将获得如下所示的输出 −
notations: undefined
浏览器很少支持此集合,但没有其他方法可以检索此数据。
dom_documenttype_object.htm