c# - Read XML using SelectSingleNode -


i using following code read specified xml

<?xml version=\"1.0\" encoding=\"utf-8\"?> <feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\">     <title>gmail - inbox xxxx@gmail.com</title>     <tagline>new messages in gmail inbox</tagline>     <fullcount>1</fullcount>     <link rel=\"alternate\" href=\"https://mail.google.com/mail\" type=\"text/html\" />     <modified>2016-02-07t12:11:21z</modified>     <entry>         <title>access less secure apps has been turned on</title>         <summary>access less secure apps has been turned on hi buddy, changed security settings so</summary>         <link rel=\"alternate\" href=\"https://mail.google.com/mail?account_id=agl.testauto@gmail.com&amp;message_id=152bb8ccd28d824b&amp;view=conv&amp;extsrc=atom\" type=\"text/html\" />         <modified>2016-02-07t11:45:12z</modified>         <issued>2016-02-07t11:45:12z</issued>         <id>tag:gmail.google.com,2004:1525516088640373323</id>         <author>             <name>google</name>             <email>no-reply@accounts.google.com</email>         </author>     </entry> </feed> 

below code being used , problem not getting values title element last line of code.

response = encoding.utf8.getstring(objclient.downloaddata("https://mail.google.com/mail/feed/atom")); response = response.replace("<feed version*\"0.3\" xmlns=\"http://purl.org/atom/01#\">", "<feed>");  xdoc.loadxml(response);  var nsmgr = new xmlnamespacemanager(xdoc.nametable); nsmgr.addnamespace("feed", "http://purl.org/atom/ns#"); node = xdoc.selectsinglenode("//feed:fullcount", nsmgr);   variables.emailcount = convert.toint16(node.innertext); system.diagnostics.debug.write(variables.emailcount);  tagline = xdoc.selectsinglenode("//feed:tagline", nsmgr).innertext;  node2 = xdoc.selectsinglenode("//feed:entry", nsmgr);  message_subject = node2.selectsinglenode("//feed/entry/title", nsmg).innertext;    ---- >>>  issue line 

just wondering issue.

thanks

try

message_subject = node2.selectsinglenode("//feed:entry/feed:title", nsmgr).innertext;

note: have used "feed" name of namespace, title should qualified


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -