You could write an XPath expression that is a union of both tag names and feed that into .selectNodes
That will give you an IXMLDOMNodeList with all of the element nodes which have either tag.
If you wanted every element node called "foo" and every element node called "bar" then this should work (the | symbol is the union operator in XPath):
Set listOfBothTags = domDoc.selectNodes("//foo | //bar")
Notes:
- the nodes will be returned in the order they appear in the document so you will get nodes of both tags mixed throughout the collection. In XPath 2.0 and later. this can be avoided by using the , operator but MSXML2 only supports XPath 1.0
- using // like this isn't very efficient so using a more specific query (e.g. "/fee/fi/foo | /fee/fi/bar") is preferable on larger documents
- the DOM document should be declared as "DOMDocument60" (early binding) or created as "DOMDocument.6.0" (late binding) Older versions of the MSXML2 DOMDocument used XSL Patterns as the query language rather than XPath but you can override this as described here