当前位置: 首页 > 网络学院 > XML相关教程 > XML DOM > getElementsByTagNameNS() 方法

XML DOM
DOM 节点
DOM 节点列表
DOM 解析
DOM 遍历节点树
DOM Mozilla 和 IE
DOM 获取节点
DOM 设置节点
DOM 删除节点
DOM 更换节点
DOM 建立节点
DOM 添加节点
DOM 克隆节点
DOM 节点类型
DOM Node
DOM NodeList
DOM NamedNodeMap
DOM Document
DOM DocumentType
DOM ProcessingInstr
DOM Element

XML DOM 中的 getElementsByTagNameNS() 方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 366 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The getElementsByTagNameNS() method returns a NodeList of all elements with a specified name and namespace.
getElementsByTagNameNS()方法的作用是:通过指定的名称和命名空间返回所有元素的节点列表。

Syntax
语法

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()”。

Example
案例

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


Try-It-Yourself Demos
自我演示

getElementByTagNameNS() - Get an element by name and namespace
getElementByTagNameNS() - 通过标签名称和命名空间获取一个元素

评论 (0) All

登陆 | 还没注册?