Latest web development tutorials

XML DOM getElementsByTagNameNS () method

Element Object Reference Element object

Definition and Usage

getElementsByTagNameNS () method returns a NodeList of all elements with the specified name and namespace.

grammar

elementNode.getElementsByTagNameNS(ns,name)

参数 描述
ns 字符串,规定要搜索的命名空间名称。值 "*" 匹配所有的标签。
name 字符串,规定要搜索的标签名。值 "*" 匹配所有的标签。


In all instances, we use XML files books_ns.xml and the JavaScript function loadXMLDoc () .

Examples

The following code fragment get element by tag name and namespace:

Examples

xmlDoc=loadXMLDoc("books_ns.xml");

x=xmlDoc.getElementsByTagNameNS("http://www.w3cschool.cc/children/","title");
document.write(x[0].nodeName);

Output:

c:title

try it"

Element Object Reference Element object