Returns a collection of elements that have the specified name.
objXMLDOMNodeList = oXMLDOMDocument.getElementsByTagName(tagName)
Object. Points to a collection of elements that match the specified name.
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 XMLDOMNodeList object is live and immediately reflects changes to the nodes that appear in the list.
More complex searches can be performed using the selectNodes method, which may also be faster in some cases.
The following example creates an XMLDOMNodeList object using the DOMDocument object's getElementsByTagName method, and then displays all of the elements with the desired tag name:
Dim ElemList Dim xmlDoc Set xmlDoc = CreateObject("Msxml2.DOMDocument") xmlDoc.async = False xmlDoc.load("c:\books.xml") Set objNodeList = xmlDoc.getElementsByTagName("AUTHOR") For i=0 To (objNodeList.length -1) MsgBox (objNodeList.item(i).xml) Next
Applies To: DOMDocument Object