How to Read a specific element value from XElement in LINQ to XML

Posted by Happy on Stack Overflow See other posts from Stack Overflow or by Happy
Published on 2012-06-01T04:23:14Z Indexed on 2012/06/01 4:40 UTC
Read the original article Hit count: 134

Filed under:
|
|

I have an XElement which has content like this.

<Response xmlns="someurl" xmlnsLi="thew3url">
   <ErrorCode></ErrorCode>
   <Status>Success</Status>
   <Result>
       <Manufacturer>
            <ManufacturerID>46</ManufacturerID>
            <ManufacturerName>APPLE</ManufacturerName>
       </Manufacturer>
      //More Manufacturer Elements like above here
   </Result>
</Response>

How will i read the Value inside Status element ?

I tried XElement stats = myXel.Descendants("Status").SingleOrDefault(); But that is returning null.

© Stack Overflow or respective owner

Related posts about c#-4.0

Related posts about linq-to-xml