How to get element by element from XmlDocument

I was able to get my first element from this list

 <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="" xmlns:xsi="" xmlns:xsd="">
    <GetITARListResponse xmlns="">

by writing

      XDocument result = new XDocument();
       result  =   ExportControl.ResultXML;
       var codes = HttpContext.Current.Server.MapPath("~/XML_Templates/codes.xml");
dynamic root = new ExpandoObject();
XmlToDynamic.Parse(root, xDoc.Elements().First());
  var result = xDoc.Descendants(XNamespace.Get("") + "code").First();

witch get the the first code “dsd”

but what if I want a foreach? and get all the code ?

or what if I want a certain code ? for exemple

var result = xDoc.Descendants(XNamespace.Get("") + "code")[2]

I would appreciate a help



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s