linq to xml navigate through xml c# -


i have xml , need able read data within.

a sample of xml

 <?xml version="1.0" ?> <consumeleadrequest xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema">   <leadtype>mortgage</leadtype>   <leadxml>     <ns1:leadassigned xmlns:ns1="http://yaddayadda" xmlns:ns0="http://yaddayadda" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance">       <ns0:lead>         <reference>1234</reference>         <product>           <mnemonic>mortgage</mnemonic>           <description>mortgage leads</description>           <subtype>other</subtype>         </product>         <extendedinfo>           <mortgage>             <mortgagevalue>75000</mortgagevalue>             <mortgagevaluelowerbound>1</mortgagevaluelowerbound>             <mortgagevalueupperbound>500</mortgagevalueupperbound>             <propertyvalue>100000</propertyvalue>             <propertyvaluelowerbound>1</propertyvaluelowerbound>             <propertyvalueupperbound>500</propertyvalueupperbound>             <adverse>false</adverse>             <firsttime>false</firsttime>           </mortgage>         </extendedinfo>         <applicants>           <applicant1>             <title>mr</title>             <forename>sampleforename</forename>             <surname>samplesurname</surname>             <dateofbirth>1903-02-01</dateofbirth>             <smoker>false</smoker>             <telephonenumbers>               <telephonenumber>                 <number>01244123456</number>                 <type>mobile</type>               </telephonenumber>             </telephonenumbers>             <emailaddresses>               <emailaddress>                 <email>test@moneysupermarket.com</email>                 <type>business</type>               </emailaddress>             </emailaddresses>             <addresses>               <address>                 <street>sample street</street>                 <district>sample district</district>                 <town>sample town</town>                 <county>sample county</county>                 <postcode>ch53uz</postcode>                 <type>home</type>               </address>             </addresses>           </applicant1>         </applicants>       </ns0:lead>       <assignment>         <price>20</price>         <assignmentdatetime>2010-02-01t00:00:00</assignmentdatetime>         <subscription>           <reference>1234</reference>           <subscriber>             <title>mr</title>             <forename>sampleforename</forename>             <surname>samplesurname</surname>           </subscriber>         </subscription>         <account>           <reference>1234</reference>           <companyname>sample company</companyname>         </account>         <leadtype>sampleleadtype</leadtype>         <territoryname>united kingdom</territoryname>       </assignment>     </ns1:leadassigned>   </leadxml>   <authenticationusername>username</authenticationusername>   <authenticationpassword>password</authenticationpassword> </consumeleadrequest> 

using linq xml how navigate items?

thanks sp

i have tried few things like

 xdocument leads = xdocument.load(@"c:\users\steven.pentleton\appdata\local\temporary projects\paaleadimport\paaexmple.xml");         var lead = (from l in leads.descendants("lead")                     select new { leadtype = (string)l.element("reference") }).tolist();         var s = lead.first();         string t = s.leadtype; 

are looking xdcoument or xelement in linq

namespace: using system.xml.linq;


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -