title: Read XML file classic ASP
body: <p>I need to read an XML document with classic ASP.</p>
  
  <p>The XML file looks like:</p>
  
  <pre><code>&lt;config&gt;
      ...
      &lt;applications&gt;
          &lt;application id="1" link="http://office.microsoft.com/en-001/word-help/what-s-new-in-word-2013-HA102809597.aspx"&gt;Word 2013&lt;/application&gt;
          &lt;application id="2" link="http://office.microsoft.com/en-001/excel-help/what-s-new-in-excel-2013-HA102809308.aspx"&gt;Excel 2013&lt;/application&gt;
          ...
      &lt;/applications&gt;
      ...
  &lt;/config&gt;
  </code></pre>
  
  <p>I want to retrieve all <code>application</code> tags and store them into a Dictionnary. The key is the application name and the value is the link attribute.</p>
  
  <p>Here is my code (<strong>corrected with the very good replies I got</strong>):</p>
  
  <pre><code>Set xmlObj = Server.CreateObject("Microsoft.XMLDOM")
  xmlObj.async = False
  xmlObj.load(Server.MapPath("/SomePath/Applications.xml"))
  
  ' List of application nodes
  Dim xmlApp : Set xmlApp = xmlObj.DocumentElement.SelectNodes("/config/applications/application")
  
  ' Dictionnary of applications
  Dim xmlAppCollection : Set xmlAppCollection = CreateObject("Scripting.Dictionary")
  ' Single application node
  Dim app
  
  For Each app In xmlApp
      ' Populate the application dictionnary
      If app.Attributes.GetNamedItem("link") Is Nothing Then
          xmlAppCollection.Add app.Text, ""
      Else
          xmlAppCollection.Add app.Text, app.Attributes.GetNamedItem("link")
      End If
  Next
  
  Response.write("Count: "&amp;xmlAppCollection.Count)
  </code></pre>
  
  <p>However, <code>xmlAppCollection.Count</code> returns zero.</p>
  
  <p>What do I miss?</p>
  
  <hr>
  
  <p><strong>UPDATE 1:</strong></p>
  
  <p>Now I've got the following error:
  <code>Object doesn't support this property or method: 'app.Value'</code>.</p>
  
  <p>The problem comes from <code>xmlAppCollection.Add app.Value, app.Attributes.GetNamedItem("link")</code></p>
  
  <hr>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>I hope this is the last question. I want to loop over the dictionary:</p>
  
  <pre><code>' applications is an array of application names
  For Each member In applications
      ' Test that the software exists in the dictionary and the link is not empty
      If xmlAppCollection.Exists(member) = True And xmlAppCollection.Item(member) &lt;&gt; "" Then
          Response.write("&lt;tr&gt;&lt;th&gt;Software&lt;/th&gt;&lt;td&gt;&lt;a href='" &amp; xmlAppCollection.Item(member) &amp; "'&gt;" &amp; member &amp; "&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;")
      Else
          Response.write("&lt;tr&gt;&lt;th&gt;Software&lt;/th&gt;&lt;td&gt;"&amp;member&amp;"&lt;/td&gt;&lt;/tr&gt;")
      End If
  Next
  </code></pre>
  
  <p>But I've got the error message: <code>Object doesn't support this property or method</code> on the line <code>If xmlAppCollection.Exists(member) = True And xmlAppCollection.Item(member) &lt;&gt; "" Then</code>. It seems to come from the <code>Item</code> <a href="http://www.w3schools.com/asp/prop_item.asp" rel="nofollow">property</a>.</p>