title: Unable to findnodes() restricted just to current parent
body: <p>I'm parsing a simple XML file to create a flat text file from it. The desired outcome is shown below the sample XML. The XML has sort of a header-detail structure (Assembly_Info and Part respectively), with a unique header node followed by any number of detail record nodes, all of which are siblings. After digging into the elements under the header, I can't then find a way back 'up' to then pick up all the sibling detail nodes. </p>
  
  <p>XML file looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" standalone="yes" ?&gt;
  &lt;Wrapper&gt;
    &lt;Record&gt;
      &lt;Product&gt;
        &lt;prodid&gt;4094&lt;/prodid&gt;
      &lt;/Product&gt;
      &lt;Assembly&gt;
        &lt;Assembly_Info&gt;
          &lt;id&gt;DF-7A&lt;/id&gt;
          &lt;interface&gt;C&lt;/interface&gt;
        &lt;/Assembly_Info&gt;
        &lt;Part&gt;
          &lt;status&gt;N/A&lt;/status&gt;
          &lt;dev_name&gt;0000&lt;/dev_name&gt;
        &lt;/Part&gt;
        &lt;Part&gt;
          &lt;status&gt;Ready&lt;/status&gt;
          &lt;dev_name&gt;0455&lt;/dev_name&gt;
        &lt;/Part&gt;
        &lt;Part&gt;
          &lt;status&gt;Ready&lt;/status&gt;
          &lt;dev_name&gt;045A&lt;/dev_name&gt;
        &lt;/Part&gt;
      &lt;/Assembly&gt;
      &lt;Assembly&gt;
        &lt;Assembly_Info&gt;
          &lt;id&gt;DF-7A&lt;/id&gt;
          &lt;interface&gt;C&lt;/interface&gt;
        &lt;/Assembly_Info&gt;
        &lt;Part&gt;
          &lt;status&gt;N/A&lt;/status&gt;
          &lt;dev_name&gt;0002&lt;/dev_name&gt;
        &lt;/Part&gt;
        &lt;Part&gt;
          &lt;status&gt;Ready&lt;/status&gt;
          &lt;dev_name&gt;0457&lt;/dev_name&gt;
        &lt;/Part&gt;
       &lt;/Assembly&gt;
    &lt;/Record&gt;
  &lt;/Wrapper&gt;
  </code></pre>
  
  <p>For each Assembly I need to read the values of the two elemenmets in Assembly_Info which I do successfully. But, I then want to read each of the Part records that are associated with the Assembly. The objective is to 'flatten' the file into this:</p>
  
  <pre><code>  prodid    id      interface   status      dev_name
      4094    DF-7A   C           N/A         0000
      4094    DF-7A   C           Ready       0455
      4094    DF-7A   C           Ready       045A
      4094    DF-7A   C           N/A         0002
      4094    DF-7A   C           Ready       0457
  </code></pre>
  
  <p>I'm attempting to use findnodes() to do this, as that's about the only tool I thought I understood. My code unfortunately reads all of the Part records from the entire file foreach Assembly--since the only way I've been able to find the Part nodes is to start at the root. I don't know how to change 'where I am', if you will; to tell findnodes to begin at current parent. Code looks like this:</p>
  
  <pre><code>my $parser = XML::LibXML -&gt; new();
  my $tree = $parser -&gt; parse_file ('DEMO.XML');
  
      for my $product ($tree-&gt;findnodes ('/Wrapper/Record/Product/prodid')) {
          $prodid = $product-&gt;textContent();
      }
  
      foreach my $assembly ($tree-&gt;findnodes ('/Wrapper/Record/Assembly')){
          $assemblies++;
          $parts = 0;
          for my $assembly ($tree-&gt;findnodes ('/Wrapper/Record/Assembly/Assembly_Info')) {
              $id = $assembly-&gt;findvalue('id');
              $interface = $assembly-&gt;findvalue('interface');
          }
  
          foreach my $part ($tree-&gt;findnodes ('/Wrapper/Record/Assembly/Part')) {
              $parts++;
              $status          = $part-&gt;findvalue('status');
              $dev_name        = $part-&gt;findvalue('dev_name');
          }
          print "Assembly No: ", $assemblies, " Parts: ",$parts, "\n";
      }
  </code></pre>
  
  <p>How do I get just the Part nodes for a given Assembly, after I've gone down to the Assembly_Info depths? There is quite a bit I'm not getting, and I think a problem may be that I'm thinking of this as 'navigating' or moving a cursor, if you will. Examples of XPath path expressions have not helped me.</p>