c# - Trying to parse xml in Windows Phone 7.8 app but getting null value? -


i trying parse xml got response webservice response xml shown below

<generalsearchresponse> <serverdetail></serverdetail> <exceptions exceptioncount="1"></exceptions> <clienttracking height="19" type="logo" width="106"></clienttracking> <searchhistory></searchhistory> <categories matchedcategorycount="1" returnedcategorycount="1"> <category id="0"> <name>bart</name> <categoryurl>http://www.shopping.com/bart/products?oq=bart&linkin_id=7000610 </categoryurl> <items matcheditemcount="1045" pagenumber="1" returneditemcount="5"> <product id="130506037"></product> <product id="104483377"></product> <offer featured="false" id="tp-vcdooo1rl6xiceronqg==" smartbuy="false" used="false"></offer> <offer featured="false" id="12evwwi57lddzfufnguwsg==" smartbuy="false" used="false"></offer> <product id="96754577"></product> </items> <attributes matchedattributecount="5" returnedattributecount="5"></attributes> <contenttype>hybrid</contenttype> </category> <intactualcategorycount>4</intactualcategorycount> </categories> <relatedterms></relatedterms> </generalsearchresponse> 

but when trying parse using following code not able descend or node

xdocument xdoc = new xdocument(); xdoc = xdocument.parse(data); var xele = xdoc.root.descendants("categories"); 

but xele not having categories. please let me know issue??

your xml has default namespace - elements in in namespace. methods find elements in linq xml namespace sensitive. want:

xnamespace ns = "urn:types.partner.api.shopping.com"; xdocument xdoc = new xdocument(); xdoc = xdocument.parse(data); var xele = xdoc.root.descendants(ns + "categories"); 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -