title: How to open a XML file in excel
body: <p>I want program my button with this features:</p>
  
  <p>open and select a xml file then write in "table2" the metric name id M1-M10 with the belonging values.</p>
  
  <p>I was successful to open and select a xml file:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Private Sub btn_load_xml_Click()
  '-----------Open file---------------------------
  Dim Filter As String, Title As String
  Dim FilterIndex As Integer
  Dim Filename As Variant
  
  ' File filters
  Filter = "XML Files (*.xml),*.xml"
  ' Default Filter to *.*
  
  FilterIndex = 3
  ' Set Dialog Caption
  Title = "Select a File to Open"
  
  ' Select Start Drive &amp; Path
  ChDrive ("C")
  ChDir ("C:")
  With Application
      ' Set File Name to selected File
      Filename = .GetOpenFilename(Filter, FilterIndex, Title)
      ' Reset Start Drive/Path
      ChDrive (Left(.DefaultFilePath, 1))
      ChDir (.DefaultFilePath)
  End With
  
  ' Exit on Cancel
  If Filename = False Then
      Exit Sub
  End If
  
  ' Open File   
  MsgBox Filename, vbInformation, "File Opened" ' This can be removed
  '------------- Load XML in table2------------------
  
  '------------- END Load XML in table2------------------
  End Sub
  </code></pre>
  
  <p>But how can I load the XML file and work with it ?</p>
  
  <p>Here is my XML structure</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  
  &lt;sourcemonitor_metrics&gt;
    &lt;project version="3.3"&gt;
      &lt;project_name&gt;metric_auswertung&lt;/project_name&gt;
      &lt;project_directory&gt;C:\Users\SULAS\Desktop\Metric_auswertung&lt;/project_directory&gt;
      &lt;project_language&gt;C&lt;/project_language&gt;
  
      &lt;ignore_headers_footers&gt;false&lt;/ignore_headers_footers&gt;
      &lt;export_raw_numbers&gt;false&lt;/export_raw_numbers&gt;
      &lt;metric_names name_count="13"&gt;
        &lt;metric_name id="M0" type="number"&gt;Lines&lt;/metric_name&gt;
        &lt;metric_name id="M1" type="number"&gt;Statements&lt;/metric_name&gt;
        &lt;metric_name id="M2" type="percent" divisor="M1"&gt;Percent Branch Statements&lt;/metric_name&gt;
        &lt;metric_name id="M3" type="percent" divisor="M0"&gt;Percent Lines with Comments&lt;/metric_name&gt;
        &lt;metric_name id="M4" type="number"&gt;Functions&lt;/metric_name&gt;
        &lt;metric_name id="M5" type="average" divisor="M4"&gt;Average Statements per Function&lt;/metric_name&gt;
        &lt;metric_name id="M6" type="string"&gt;Line Number of Most Complex Function&lt;/metric_name&gt;
        &lt;metric_name id="M7" type="string"&gt;Name of Most Complex Function&lt;/metric_name&gt;
        &lt;metric_name id="M8" type="maximum"&gt;Complexity of Most Complex Function&lt;/metric_name&gt;
        &lt;metric_name id="M9" type="string"&gt;Line Number of Deepest Block&lt;/metric_name&gt;
        &lt;metric_name id="M10" type="maximum"&gt;Maximum Block Depth&lt;/metric_name&gt;
        &lt;metric_name id="M11" type="average" values="block_depths"&gt;Average Block Depth&lt;/metric_name&gt;
        &lt;metric_name id="M12" type="average"&gt;Average Complexity&lt;/metric_name&gt;
      &lt;/metric_names&gt;
      &lt;checkpoints checkpoint_count="1"&gt;
        &lt;checkpoint checkpoint_name="Metric_Auswertung" ignore_blank_lines="false" modified_complexity="true" checkpoint_date="2013-02-25"&gt;
          &lt;files file_count="3"&gt;
            &lt;file file_name="Mcu - Kopie.c"&gt;
              &lt;metrics metric_count="13"&gt;
                &lt;metric id="M0"&gt;603&lt;/metric&gt;
                &lt;metric id="M1"&gt;183&lt;/metric&gt;
                &lt;metric id="M2"&gt;26,2&lt;/metric&gt;
                &lt;metric id="M3"&gt;23,2&lt;/metric&gt;
                &lt;metric id="M4"&gt;11&lt;/metric&gt;
                &lt;metric id="M5"&gt;24,6&lt;/metric&gt;
                &lt;metric id="M6"&gt;321&lt;/metric&gt;
                &lt;metric id="M7"&gt;Mcu_GetPllStatus()&lt;/metric&gt;
                &lt;metric id="M8"&gt;15&lt;/metric&gt;
                &lt;metric id="M9"&gt;235&lt;/metric&gt;
                &lt;metric id="M10"&gt;6&lt;/metric&gt;
                &lt;metric id="M11"&gt;1,97&lt;/metric&gt;
                &lt;metric id="M12"&gt;6,00&lt;/metric&gt;
              &lt;/metrics&gt;
            &lt;/file&gt;
          &lt;/files&gt;
        &lt;/checkpoint&gt;
      &lt;/checkpoints&gt;
    &lt;/project&gt;
  &lt;/sourcemonitor_metrics&gt;
  </code></pre>