title: Excel VBA - XML DomDocument return attribute values
body: <p>I am working with the following XML response in Excel VBA.</p>
  
  <pre><code>&lt;XXXXX docType="GetSegmentSpeed" copyright="Copyright XXXXX Inc." versionNumber="12.9" createdDate="2018-11-26T15:08:37Z" statusId="0" statusText="" responseId="06d3aad3-c3aa-40a5-9d2c-f1ac8f713729"&gt;
     &lt;SegmentSpeedResultSet coverage="255"&gt;
        &lt;SegmentSpeedResults timestamp="2018-11-26T15:08:36Z"&gt;
           &lt;Segment code="213423027" type="XDS" speed="53" average="34" reference="40" score="30" c-value="63" travelTimeMinutes="0.649" speedBucket="3"/&gt;
           &lt;Segment code="213423023" type="XDS" speed="53" average="38" reference="41" score="30" c-value="58" travelTimeMinutes="0.603" speedBucket="3"/&gt;
           &lt;Segment code="213423026" type="XDS" speed="52" average="34" reference="39" score="30" c-value="71" travelTimeMinutes="0.486" speedBucket="3"/&gt;
           &lt;Segment code="213423050" type="XDS" speed="52" average="34" reference="39" score="30" c-value="71" travelTimeMinutes="0.48" speedBucket="3"/&gt;
           &lt;Segment code="213423051" type="XDS" speed="52" average="35" reference="39" score="30" c-value="78" travelTimeMinutes="0.486" speedBucket="3"/&gt;
        &lt;/SegmentSpeedResults&gt;
     &lt;/SegmentSpeedResultSet&gt;
  &lt;/XXXXX&gt; 
  </code></pre>
  
  <p>I want to find the total of the <em>travelTimeMinutes</em> attributes of <em>Segments</em>.</p>
  
  <p>To begin with, I thought I would try and get the value for the first segment. This is my code:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Sub SegSetTimes()
  
     ' Declare Private Variables
     Dim SegString As String 'Segment set to be used for calculation
     Dim hReq As New WinHttpRequest 'HttpRequest path
     Dim strResp As String 'Response String
     Dim xmlDoc As MSXML2.DOMDocument60 'DomDocument for parsing XML
  
     ' Import Segment Set
     SegString = Join(WorksheetFunction.Transpose(Range("A2", Range("A2").End(xlDown)).Value), "|XDS,")
  
     ' Call for real-time segment information
     hReq.Open "Get", "http://eu.api.XXXXX.com/Traffic/XXXXX.ashx?Action=GetSegmentSpeed" &amp; "&amp;token=" &amp; AuthToken &amp; "&amp;Segments=" &amp; SegString
     hReq.Send
     ' Create string from response text
     strResp = hReq.ResponseText
  
     ' Import response text into DomDocument for parsing within VBA
     Set xmlDoc = New MSXML2.DOMDocument60
     If Not xmlDoc.LoadXML(strResp) Then
        MsgBox "Load Error"
     End If
  
     Dim n As IXMLDOMNodeList
     Set n = xmlDoc.SelectNodes("//XXXXX/SegmentSpeedResultSet/SegmentSpeedResults")
  
     Dim TT As Single
     TT = n.Item(0).Attributes.getNamedItem("travelTimeMinutes")
  
  End Sub
  </code></pre>
  
  <p>It fails with the following error:</p>
  
  <blockquote>
    <p>Run-time error '91': Object variable or With block variable not set'</p>
  </blockquote>
  
  <p>When stepping through in <em>Locals</em>, my <code>IXMLDOMNodeList</code> <em>n</em> looks correct. I just cannot see how to get at the values I want to.</p>
  
  <p>Does anybody have any suggestions?</p>