title: Bring back sibling values within a parent node
body: <pre><code>&lt;po-response xmlns="http://test.com/oms/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="rest/oms/export/v3/purchase-order.xsd"&gt;
    &lt;!--Generated on host [spapp403p.prod.ch4.s.com]--&gt;
    &lt;purchase-order&gt;
      &lt;customer-order-confirmation-number&gt;335342876&lt;/customer-order-confirmation-number&gt;
      &lt;customer-email&gt;123456@test.com&lt;/customer-email&gt;
      &lt;po-number&gt;12345&lt;/po-number&gt;
      &lt;po-date&gt;2012-02-29&lt;/po-date&gt;
      &lt;po-time&gt;13:02:59&lt;/po-time&gt;
      &lt;po-number-with-date&gt;201202292988262&lt;/po-number-with-date&gt;
      &lt;unit&gt;9301&lt;/unit&gt;
      &lt;site&gt;Test&lt;/site&gt;
      &lt;channel&gt;VD&lt;/channel&gt;
      &lt;location-id&gt;1234&lt;/location-id&gt;
      &lt;expected-ship-date&gt;2013-06-05&lt;/expected-ship-date&gt;
      &lt;shipping-detail&gt;
        &lt;ship-to-name&gt;JOHN DOH&lt;/ship-to-name&gt;
        &lt;address&gt;1234 MADE UP LANE&lt;/address&gt;
        &lt;city&gt;BLAH&lt;/city&gt;
        &lt;state&gt;KK&lt;/state&gt;
        &lt;zipcode&gt;1234&lt;/zipcode&gt;
        &lt;phone&gt;666123456&lt;/phone&gt;
        &lt;shipping-method&gt;Ground&lt;/shipping-method&gt;
      &lt;/shipping-detail&gt;
      &lt;customer-name&gt;JOHN DOH&lt;/customer-name&gt;
      &lt;po-line&gt;
        &lt;po-line-header&gt;
          &lt;line-number&gt;3&lt;/line-number&gt;
          &lt;item-id&gt;ABC-12345&lt;/item-id&gt;
          &lt;item-name&gt;Professional Chrome Dumbbell 1&lt;/item-name&gt;
          &lt;selling-price-each&gt;12.76&lt;/selling-price-each&gt;
          &lt;commission&gt;1.52&lt;/commission&gt;
          &lt;order-quantity&gt;2&lt;/order-quantity&gt;
          &lt;shipping-and-handling&gt;12.66&lt;/shipping-and-handling&gt;
        &lt;/po-line-header&gt;
        &lt;po-line-detail&gt;
          &lt;po-line-status&gt;NEW&lt;/po-line-status&gt;
          &lt;quantity&gt;2&lt;/quantity&gt;
        &lt;/po-line-detail&gt;
      &lt;/po-line&gt;
      &lt;po-line&gt;
        &lt;po-line-header&gt;
          &lt;line-number&gt;2&lt;/line-number&gt;
          &lt;item-id&gt;BCD-33022&lt;/item-id&gt;
          &lt;item-name&gt;Professional Chrome Dumbbell 2&lt;/item-name&gt;
          &lt;selling-price-each&gt;13.82&lt;/selling-price-each&gt;
          &lt;commission&gt;1.14&lt;/commission&gt;
          &lt;order-quantity&gt;2&lt;/order-quantity&gt;
          &lt;shipping-and-handling&gt;18.66&lt;/shipping-and-handling&gt;
        &lt;/po-line-header&gt;
        &lt;po-line-detail&gt;
          &lt;po-line-status&gt;NEW&lt;/po-line-status&gt;
          &lt;quantity&gt;2&lt;/quantity&gt;
        &lt;/po-line-detail&gt;
      &lt;/po-line&gt;
      &lt;po-line&gt;
        &lt;po-line-header&gt;
          &lt;line-number&gt;1&lt;/line-number&gt;
          &lt;item-id&gt;CDE-33021&lt;/item-id&gt;
          &lt;item-name&gt;Professional Chrome Dumbbell 3&lt;/item-name&gt;
          &lt;selling-price-each&gt;15.88&lt;/selling-price-each&gt;
          &lt;commission&gt;1.76&lt;/commission&gt;
          &lt;order-quantity&gt;2&lt;/order-quantity&gt;
          &lt;shipping-and-handling&gt;18.68&lt;/shipping-and-handling&gt;
        &lt;/po-line-header&gt;
        &lt;po-line-detail&gt;
          &lt;po-line-status&gt;NEW&lt;/po-line-status&gt;
          &lt;quantity&gt;1&lt;/quantity&gt;
        &lt;/po-line-detail&gt;
      &lt;/po-line&gt;
      &lt;order-total-sell-price&gt;42.92&lt;/order-total-sell-price&gt;
      &lt;total-commission&gt;1.42&lt;/total-commission&gt;
      &lt;total-shipping-handling&gt;46.00&lt;/total-shipping-handling&gt;
      &lt;balance-due&gt;67.50&lt;/balance-due&gt;
      &lt;sales-tax&gt;15.13&lt;/sales-tax&gt;
      &lt;po-status&gt;New&lt;/po-status&gt;
    &lt;/purchase-order&gt;
  &lt;purchase-order&gt;
  .
  .
  .
  </code></pre>
  
  <p>I need a way to bring back all the details within the  in particular I'm having a issue as there can be any number of  's in the case above there is three of them and i need to loop through these within the  and then move onto the next.</p>
  
  <p>I was using the following code using XDcoument which worked fine with only one po-line but but can't get it to work with more than one.</p>
  
  <pre><code>xmlDoc = XDocument.Parse(sr.ReadToEnd());
  XNamespace ns = "http://test.com/oms/v3";
  var purchaseOrders = from purchaseOrder in xmlDoc.Descendants(ns + "purchase-order")
      select new
      {        
           PurcaseOrderNo = purchaseOrder.Element(ns + "po-number").Value,
           PurchaseDate = purchaseOrder.Element(ns + "po-date").Value,
           CustomerFullName = purchaseOrder.Element(ns + "customer-name").Value,
           ItemId = purchaseOrder.Element(ns + "po-line").Element(ns + "po-line-header").Element(ns + "item-id").Value,
      };
  </code></pre>
  
  <p>I've looked at using a foreach loop and iterating through the nodes using something like this but i need to bring back the other information for that order not just limit the results to whats in the  nodes</p>
  
  <pre><code>foreach (XElement po in xmlDoc.Descendants(ns + "po-line"))
  {
      string ItemId = po.Element(ns + "po-line-header").Element(ns + "item-id").Value;
      string SellingPrice = po.Element(ns + "po-line-header").Element(ns + "selling-price-each").Value;                                                        
  }
  </code></pre>
  
  <p>I'm looking for the best way of doing this, perhaps a combination of the two or a fresh approach is required?</p>
  
  <p>So the results I need is a single line for example something like this for each purchase order where customer details will be the same but the itemId will change:</p>
  
  <pre><code> customer email, po-number, ship-to name, item-id
  
      123456@test.com, 12345, JOHN DOH, ABC-12345
      123456@test.com, 12345, JOHN DOH, BCD-33022
  </code></pre>