Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>what i'm after is a list of Userbeans, which are in themselves a list</p> </blockquote> <p>You need to think in terms of "nodes", not "lists." <code>selectNodes</code> returns a pointer to a set of nodes, but when you iterate through it you wind up with an IXMLDOMNode, not a Node List. You can only get a nodeList by calling a method, such as selectNodes.</p> <p>You can to call selectNodes <em>again</em>, or just use the IXMLDOMNode's <code>childNodes</code> property, <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms757053.aspx" rel="nofollow">Documented at MSDN</a></p> <pre><code>Dim userBeanList As MSXML2.IXMLDOMNodeList Dim userbean As MSXML2.IXMLDOMNode Dim beanChild As MSXML2.IXMLDOMNode Set userBeanList = xmlDoc.selectNodes("//UserBean") For Each userBean In userBeanList For Each beanChild In userBean.childNodes Debug.Print beanChild.nodeName &amp; ":" &amp; beanChildText Next beanChild Next userBean </code></pre> <p>Note that with a proper XPath Query, you can just select a list of nodes that meet your criteria. And since this is VBA, you can skip the explicit declarations unless you're going to take advantage of the intellisense.</p> <pre><code>dim badNodes, badNode set badNodes = xmlDoc.selectNodes("//UserBean/*[not(text())]") if badNodes.length &lt; 1 then debug.Print "All good!" else debug.Print "following nodes are empty:" For Each badNode in badNodes debug.print " - " &amp; badNode.name next badNode endif </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload