dd

XML DOM hasAttributeNS() 方法


定义和用法

hasAttributeNS() 方法在当前元素节点拥有匹配指定命名空间和名称的属性时返回 TRUE,否则返回 FALSE。

语法

hasAttributeNS(ns,name)


参数描述
ns必需。规定要查找的属性的命名空间。
name必需。规定要查找的属性的名称。

实例

下面的代码片段使用 loadXMLDoc() 把 "books_ns.xml" 载入 xmlDoc 中,并检查第一个 <title> 元素是否拥有指定命名空间和名称的属性:

实例

xmlDoc=loadXMLDoc("books_ns.xml");

x=xmlDoc.getElementsByTagName("title")[0];
ns="http://www.shouce.ren/children/";

document.write(x.hasAttributeNS(ns,"lang"));

输出:

true