title: Loop through XML and return element values
body: <p>Here is my XML doc:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;FileScan&gt;
      &lt;Sites&gt;
          &lt;Site&gt;
              &lt;Name&gt;Joe&lt;/Name&gt;
              &lt;Dir&gt;\\webserver\ftp\Joe&lt;/Dir&gt;
              &lt;Email&gt;Joe@anycompany.com&lt;/Email&gt;
              &lt;Subject&gt;Hi Joe!&lt;/Subject&gt;
          &lt;/Site&gt;
          &lt;Site&gt;
              &lt;Name&gt;Ben&lt;/Name&gt;
              &lt;Dir&gt;\\webserver\ftp\ben&lt;/Dir&gt;
              &lt;Email&gt;ben@anycompany.com, benjamin@anycompany.com&lt;/Email&gt;
              &lt;Subject&gt;Hi Ben!&lt;/Subject&gt;
          &lt;/Site&gt;
          &lt;Site&gt;
              &lt;Name&gt;Ian&lt;/Name&gt;
              &lt;Dir&gt;\\webserver\ftp\Ian&lt;/Dir&gt;
              &lt;Email&gt;Ian@anycompany.com&lt;/Email&gt;
              &lt;Subject&gt;You are fired!&lt;/Subject&gt;
          &lt;/Site&gt;
          &lt;Site&gt;
              &lt;Name&gt;Mark&lt;/Name&gt;
              &lt;Dir&gt;\\webserver\ftp\Mark&lt;/Dir&gt;
              &lt;Email&gt;Mark@anycompany.com&lt;/Email&gt;
              &lt;Subject&gt;Hi Mark&lt;/Subject&gt;
          &lt;/Site&gt;
      &lt;/Sites&gt;
  &lt;/FileScan&gt;
  </code></pre>
  
  <p>What I want to do is:</p>
  
  <pre class="lang-none prettyprint-override"><code>Open xmlDoc
  Do while xmlDoc.eof &lt;&gt; true
     store &lt;Name&gt; to varNAME
     store &lt;Dir&gt; to varDIR
     store &lt;Email&gt; to varEMAIL
     store &lt;Subject&gt; to varSUBJECT
     Then run an already designed function
     Move to next XML &lt;Site&gt; tag
  Loop
  </code></pre>
  
  <p>Currently this is what I have:</p>
  
  <pre class="lang-vbs prettyprint-override"><code>Set xmlDoc = CreateObject("Microsoft.XMLDOM")
  
  xmlDoc.Async = "False"
  xmlDoc.Load("FileScan.xml")
  Set colNodes = xmlDoc.selectNodes ("//Site/ (Name|Dir)")
  For Each objNode in colNodes
      WScript.Echo objNode.nodeName &amp; ": " &amp; objNode.text
  Next
  </code></pre>
  
  <p>I am getting the Name and Dir in the popup, but I cant seem to store them into variables by element name. How can I refer to an element by its particular name and be sure it is the right element. Then do that over and over as the number of sites may change over time?</p>