Note that there are some explanatory texts on larger screens.

plurals
  1. POAccess XML using Linq
    primarykey
    data
    text
    <p>I have XML document with this structure:</p> <pre><code>&lt;dipOrders&gt; &lt;interchangeInfo senderEdiCode="LSC58" senderEdiCodeQal="ZZ" receiverEdiCode="15274" receiverEdiCodeQal="ZZ" syntax="X12" syntaxId="X" syntaxVersion="003010"/&gt; &lt;order orderNumber="219299" orderDate="2012-12-05T00:00:00" validityDate="2012-12-05T00:00:00"&gt; &lt;buyer name="LEAR MTO"&gt; &lt;partyCode buyerCode="811567924"/&gt; &lt;/buyer&gt; &lt;supplier name="BRIDGE OF WEIR LEATHER CO"&gt; &lt;partyCode buyerCode="749630"/&gt; &lt;/supplier&gt; &lt;orderConsignee name="LEAR MEXICAN SEATING CORP"&gt; &lt;partyCode buyerCode="LSC59"/&gt; &lt;orderLine description="LEA DC 378 HERO 6RSB 5B8" orderNumber="246767" engineeringChangeNumber="N"&gt; &lt;partyCode buyerCode="DC378105H6RSB5B8AA"/&gt; &lt;cumulativeQuantity date="2012-12-04T00:00:00" quantity="0"/&gt; &lt;orderQuantity quantity="0" commitmentLevel="Firm" timingQualifier="Weekly" shipDate="2012-12-05T00:00:00"/&gt; &lt;/orderLine&gt; &lt;orderLine description="LEA DC 378 HERO 6RSB 5V0" orderNumber="246767" engineeringChangeNumber="N"&gt; &lt;partyCode buyerCode="DC378105H6RSB5V0AA"/&gt; &lt;cumulativeQuantity date="2012-12-04T00:00:00" quantity="0"/&gt; &lt;orderQuantity quantity="0" commitmentLevel="Firm" timingQualifier="Weekly" shipDate="2012-12-05T00:00:00"/&gt; &lt;/orderLine&gt; </code></pre> <p>I am trying to access it with Linq to XML in .NET console application to get orderLine item details:</p> <pre><code>XDocument doc = XDocument.Load(sourceDirectory + "\\" + fileName); var data = from item in doc.Descendants("orderLine") select new { orderNumber = item.Element("orderNumber").Value }; foreach (var i in data) { Console.WriteLine(i.ToString()); } Console.ReadLine(); </code></pre> <p>But I get "object reference not set to an instance of an object" error. Why?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload