DOM - 实体对象属性 - notationName

属性 notationName 给出未解析实体的符号名称和值。对于已解析的实体,其值为 null。

语法

以下是使用 notationName 属性的语法。

----------

示例

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>

以下示例演示了 notationName 属性的用法 −

<!DOCTYPE html>
<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");

         x = xmlDoc.getElementsByTagName('address');
         document.write("Name of the attribute notation is : ")
         document.write(x.item(0).attributes[0].nodeName);
         document.write("<br>")
         document.write("Value of the attribute notation is : ");
         document.write(x.item(0).attributes[0].nodeValue);
      </script>
   </body>
</html>

执行

将此文件保存为服务器路径上的 entityattribute_notations.html(此文件和 notation.xml 应位于服务器中的同一路径)。我们将获得如下所示的输出 −

Name of the attribute notation is : name
Value of the attribute notation is : Tanmay
dom_entity_object.htm