title: Getting values from all nodes with specific name from XML
body: <p>I'm having problem with the most efficient way to get all the values of the nodes with certain name from XML.</p>
  
  <p>For example:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;h1&gt;
  &lt;MyNode&gt;Node One&lt;/MyNode&gt;
  &lt;h2&gt;
      &lt;MyNode&gt;Note Two&lt;/MyNode&gt;
      &lt;DiffrentNode&gt;I dont want that&lt;/DiffrentNode&gt;
      &lt;h3&gt;
          &lt;MyNode&gt;Node Three&lt;/MyNode&gt;
      &lt;/h3&gt;
  &lt;/h2&gt;
  &lt;HHH1&gt;
      &lt;MyNode&gt;Node Four&lt;/MyNode&gt;
  &lt;/HHH1&gt;
  &lt;/h1&gt;
  &lt;g2&gt;
      &lt;MyNode&gt;Node Five&lt;/MyNode&gt;
  &lt;/g2&gt;
  </code></pre>
  
  <p>From the XML I want to get these values:</p>
  
  <ul>
  <li>Node One</li>
  <li>Node Two</li>
  <li>Node Three</li>
  <li>Node Four</li>
  <li>Node Five</li>
  </ul>
  
  <p>I'd like to be able to do the same with code like that:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;h1&gt;
  &lt;h2 MyArgument = "Argument One" Stuff = "I dont want that"&gt;
      &lt;DiffrentNode&gt;Something I dont want&lt;/DiffrentNode&gt;
      &lt;h3 MyArgument = "Argument Two" Stuff = "I dont want that too"&gt;
      &lt;/h3&gt;
  &lt;/h2&gt;
  &lt;HHH1&gt;
      &lt;DiffrentNode&gt;Something I dont want&lt;/DiffrentNode&gt;
  &lt;/HHH1&gt;
  &lt;/h1&gt;
  &lt;g2 MyArgument = "Argument Three"&gt;
      &lt;DiffrentNode&gt;Something I dont want&lt;/DiffrentNode&gt;
  &lt;/g2&gt;
  </code></pre>
  
  <p>and get:</p>
  
  <ul>
  <li>Argument One</li>
  <li>Argument Two</li>
  <li>Argument Three</li>
  </ul>
  
  <p>Any ideas? So far I tried doing:</p>
  
  <pre class="lang-psh prettyprint-override"><code>$xdoc = New-Object System.Xml.XmlDocument
  $file = Resolve-Path("C:\CompiledDynoview.xml")
  $xdoc.load($file)
  [xml] $xdoc = Get-Content $file
  $xdoc.h1.MyNode
  $xdoc.h1.h2.MyNode
  $xdoc.h1.h3.MyNode
  ...
  </code></pre>
  
  <p>But it doesn't seem to be the best way. There should be something better.</p>