Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

Returns a collection of elements that have the specified name.

Script Syntax

Copy Code
var objXMLDOMNodeList =
oXMLDOMDocument.getElementsByTagName(
tagName);

Remarks

Script Parameters

tagName

String specifying the element name to find. The tagName"*" returns all elements in the document.

Script Return Value

Object. Points to a collection of elements that match the specified name.

C/C++ Syntax

Copy Code
HRESULT getElementsByTagName(
  BSTR 
tagName,
  IXMLDOMNodeList** 
resultList
);

Remarks

C/C++ Parameters

tagName

[in] Element name to find. The tagname "*" returns all elements in the document.

resultList

[out, retval] Address of a collection of elements that match the specified name.

C/C++ Return Values

S_OK

Value returned if successful.

Requirements

Header msxml2.h, msxml2.idl
Library uuid.lib
Windows Embedded CE Windows CE .NET 4.0 and later

General Remarks

This method is only valid if the XML Query Language (XQL) feature has been included in the operating system (OS). If a call to this method is made and XQL is not supported, an error message will be returned.

The elements in the collection are returned in the order in which they would be encountered in a preorder traversal of the document tree. In a preorder traversal, the parent root node is visited first and each child node from left to right is then traversed.

The returned IXMLDOMNodeListobject is live and immediately reflects changes to the nodes that appear in the list.

More complex searches can be performed using the selectNodes Method. This method can also be faster in some cases.

This method applies to the following objects and interfaces:

DOMDocumentand IXMLDOMNodeList.

See Also