当前位置: 首页 > 网络学院 > XML相关教程 > XML DOM > getElementsByTagNameNS() 方法
XML DOM 中的 getElementsByTagNameNS() 方法
出处:互联网 整理: 软晨网(RuanChen.com) 发布: 2009-03-04 浏览: 255 ::
The getElementsByTagNameNS() method returns a NodeList of all elements with a specified name and namespace.
getElementsByTagNameNS()方法的作用是:通过指定的名称和命名空间返回所有元素的节点列表。
elementNode.getElementsByTagNameNS(ns,name) |
| Parameter 参数 | Description 描述 |
|---|---|
| ns | A string that specifies the namespace to search for. The value "*" matches all tags 指定一个用于指明需要执行搜索操作的命名空间的字符串。通配符“*”将匹配所有的标签 |
| name | A string that specifies the tagname to search for. The value "*" matches all tags 指定一个用于指明需要执行搜索操作的标签名称的字符串。通配符“*”将匹配所有的标签 |
In all examples, we will use the XML file books_ns.xml, and the JavaScript function loadXMLDoc().
在所有案例中,我们将使用“books_ns.xml”文件以及JavaScript 函数“loadXMLDoc()”。
The following code fragment gets an element by tag name and namespace:
下面的代码片断将通过标签名称和命名空间获取一个元素:
xmlDoc=loadXMLDoc("books_ns.xml");
var x=xmlDoc.getElementsByTagNameNS("http://www.w3schools.com/children/","title");
document.write(x[0].nodeName); |
Output:
输出结果:
c:title |
getElementByTagNameNS() - Get an element by name and namespace
getElementByTagNameNS() - 通过标签名称和命名空间获取一个元素
评论 (0) All