XML DOM getElementsByTagName () method
Definition and Usage
getElementsByTagName () method returns a NodeList of all elements with the specified name.
grammar
getElementsByTagName(name)
参数 | 描述 |
---|---|
name | 字符串,规定要搜索的标签名。值 "*" 匹配所有的标签。 |
Examples
The following code fragment uses loadXMLDoc () to " the Books.xml " into xmlDoc, and displays the first value <title> element:
Examples
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName("title")[0]
y=x.childNodes[0];
document.write(y.nodeValue);
x=xmlDoc.getElementsByTagName("title")[0]
y=x.childNodes[0];
document.write(y.nodeValue);
Output:
Everyday Italian
try it"
Document Object