title: Excel VBA getting specific node from XML
body: <p>I have an XML file from a URL API (the URL I have not shared since it allows access to secure info). From this file I want to get certain info out. My problem is, once I am in the parent node (eventNode) I want to simply be able to get the data from specific child nodes. </p>
  
  <p>For example if eventNode was <code>&lt;event&gt;&lt;ID&gt;1&lt;/ID&gt;...&lt;title&gt;event 1&lt;/title&gt;&lt;/event&gt;</code>, how would I get <code>1</code> from just knowing the node name is <code>ID</code> (or any other value I want to pull out)?</p>
  
  <p>I have looked a lot through forums and the <code>.SelectSingleNode</code> has given me no luck. Also <code>.selectNodes</code> will not act like a normal list of nodes in an XML string. I don't know if this is due to the method I'm using to parse my XML file.</p>
  
  <pre><code>Sub ListEvents()
  
  Dim strPath As String
  
  strPath = getAPI("GetEvents", "filter=&amp;orderBy=")
  
  Dim xmlDocument As MSXML2.DOMDocument60
  Set xmlDocument = New DOMDocument60
  
  With CreateObject("MSXML2.XMLHTTP")
      .Open "GET", strPath, False
      .send
      xmlDocument.LoadXML .responseText
  End With
  
  Dim lvl1 As IXMLDOMNode: Dim lvl2 As IXMLDOMNode
  Dim eventNode As IXMLDOMNode: Dim isNode As IXMLDOMNode
  
  For Each lvl1 In xmlDocument.ChildNodes
      For Each lvl2 In lvl1.ChildNodes
          For Each eventNode In lvl2.ChildNodes
              If eventNode.HasChildNodes Then
                  'Here is where I want code to find specific child node
                  'without having to look at every node.
              End If
          Next
      Next
  Next
  
  End Sub
  </code></pre>
  
  <p>Sample XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; 
  &lt;ResultsOfListOfEvent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.regonline.com/api"&gt;
    &lt;Success&gt;true&lt;/Success&gt; 
    &lt;Data&gt;
      &lt;APIEvent&gt;
        &lt;ID&gt;111&lt;/ID&gt; 
        &lt;CustomerID&gt;222&lt;/CustomerID&gt; 
        &lt;ParentID&gt;0&lt;/ParentID&gt; 
        &lt;Status&gt;Testing&lt;/Status&gt; 
        &lt;Title&gt;Event Name&lt;/Title&gt; 
        &lt;ClientEventID /&gt; 
        &lt;TypeID&gt;9&lt;/TypeID&gt; 
        &lt;TimeZone&gt;GMT&lt;/TimeZone&gt; 
        &lt;CurrencyCode&gt;GBP&lt;/CurrencyCode&gt; 
        &lt;AddDate&gt;2013-12-18T02:34:09.357&lt;/AddDate&gt; 
        &lt;Channel&gt;Running&lt;/Channel&gt; 
        &lt;IsWaitlisted&gt;false&lt;/IsWaitlisted&gt; 
      &lt;/APIEvent&gt;
      &lt;APIEvent&gt;
        &lt;ID&gt;112&lt;/ID&gt; 
        &lt;CustomerID&gt;223&lt;/CustomerID&gt; 
        &lt;ParentID&gt;0&lt;/ParentID&gt; 
        &lt;Status&gt;Testing&lt;/Status&gt; 
        &lt;Title&gt;Event Name&lt;/Title&gt; 
        &lt;ClientEventID /&gt; 
        &lt;TypeID&gt;9&lt;/TypeID&gt; 
        &lt;TimeZone&gt;GMT&lt;/TimeZone&gt; 
        &lt;CurrencyCode&gt;GBP&lt;/CurrencyCode&gt; 
        &lt;AddDate&gt;2013-12-18T02:34:09.357&lt;/AddDate&gt; 
        &lt;Channel&gt;Running&lt;/Channel&gt; 
        &lt;IsWaitlisted&gt;false&lt;/IsWaitlisted&gt; 
      &lt;/APIEvent&gt;
    &lt;/Data&gt;
  &lt;/ResultsOfListOfEvent&gt;
  </code></pre>
  
  <p>I want to output the text in each <code>&lt;ID&gt;</code> (i.e. <code>111</code> and <code>112</code>) and each <code>&lt;Title&gt;</code>. This is only an example, depending on the API I run I will want to be able to pick and choose what information I pull.</p>