title: Identifying a particular node in XML using PowerShell
body: <p>I am working with an XML document and I am not sure how to parse it to find a particular node.</p>
  
  <p>In the example below I'd be searching for the  ProductB and expecting to identify the  Bee Hive</p>
  
  <pre><code>&lt;PRODUCTS&gt;
      &lt;PRODUCT_LEVEL_1&gt;
          &lt;PRODUCT_ID&gt;ProductA&lt;/PRODUCT_ID&gt;
          &lt;PRODUCT_NAME&gt;Ant Hill&lt;/PRODUCT_NAME&gt;
          &lt;PRODUCT_ID&gt;ProductB&lt;/PRODUCT_ID&gt;
          &lt;PRODUCT_NAME&gt;Bee Hive&lt;/PRODUCT_NAME&gt;
          &lt;PRODUCT_ID&gt;ProductC&lt;/PRODUCT_ID&gt;
          &lt;PRODUCT_NAME&gt;Centipede Hotel&lt;/PRODUCT_NAME&gt;
      &lt;/PRODUCT_LEVEL_1&gt;
  &lt;/PRODUCTS&gt;
  </code></pre>
  
  <p>I'm not even sure how to refer to this format of XML which is making it difficult to search for.</p>
  
  <p>Any assistance gratefully received.</p>
  
  <p>Edit: At present I am loading the XML from a file using the following:</p>
  
  <pre><code>System.Xml.XmlDocument] $xd = new-object System.Xml.XmlDocument
  $file = resolve-path($inputFile)
  $xd.load($file)
  $nodelist = $xd.selectnodes("/PRODUCTS/PRODUCT_LEVEL_1")
  foreach ($documentNode in $nodelist) {
      #do some stuff
  }
  </code></pre>
  
  <p>The actual XML file has loads of other junk in too but I stripped it out in the hopes of focusing on the bits I need.  Perhaps I have stripped too much and the context has been lost?</p>