c# - Read Complex Rss feed -


hi i'am try read digg feed, code doesnt not return item rss, think namespace problem

<?xml version="1.0" encoding="utf-8"?> <feed xml:lang="en-us" xmlns="http://www.w3.org/2005/atom" xmlns:digg="http://digg.com/docs/diggrss/" xmlns:media="http://search.yahoo.com/mrss/"> <title>top news</title> <subtitle>top news</subtitle> <updated>2012-03-10t13:27:08z</updated> <link href="http://services.digg.com/2.0/story.gettopnews?type=rss" rel="self"/> <id>http://services.digg.com/2.0/story.gettopnews?type=rss</id> <link href="http://pubsubhubbub.appspot.com/" rel="hub"/> <author> <name>digg</name> </author> <entry> <title>the windows 8 power struggle: metro vs desktop , why don't mesh well</title> <link href="http://digg.com/news/technology/the_windows_8_power_struggle_metro_vs_desktop_and_why_they_don_t_mesh_well?utm_campaign=feed%3a+http%3a%2f%2fservices.digg.com%2f2.0%2fstory.gettopnews%3ftype%3drss&amp;utm_medium=feed&amp;utm_source=diggapi"/> <content type="html">metro, microsoft's new ui, bold, dramatic departure company has done in desktop/laptop space, , absolutely great. it's tangible proof redmond can design , build own unique products , experiences. however, transition metro's start, desktop users, jarring , worse yet, desktop mode , metro don't mesh @ all..</content> <updated>2012-03-09t17:12:03z</updated> <digg:diggcount> 92 </digg:diggcount> <digg:category> technology </digg:category> <digg:commentcount> 3 </digg:commentcount> <media:thumbnail height="62" url="http://cdn1.diggstatic.com/story/the_windows_8_power_struggle_metro_vs_desktop_and_why_they_don_t_mesh_well/t.png" width="62"/> <media:group> <media:content height="160" url="http://cdn3.diggstatic.com/story/the_windows_8_power_struggle_metro_vs_desktop_and_why_they_don_t_mesh_well/l.png" width="160"/> <media:content height="48" url="http://cdn1.diggstatic.com/story/the_windows_8_power_struggle_metro_vs_desktop_and_why_they_don_t_mesh_well/s.png" width="48"/> <media:content height="120" url="http://cdn1.diggstatic.com/story/the_windows_8_power_struggle_metro_vs_desktop_and_why_they_don_t_mesh_well/m.png" width="120"/> <media:content height="62" url="http://cdn1.diggstatic.com/story/the_windows_8_power_struggle_metro_vs_desktop_and_why_they_don_t_mesh_well/t.png" width="62"/> </media:group> <id>http://digg.com/news/technology/the_windows_8_power_struggle_metro_vs_desktop_and_why_they_don_t_mesh_well</id> </entry> 

with sample of code

  var xmlpath = "/feed/entry";       var xmldoc = new xmldocument();     var webclient = new webclient();     var stream = new memorystream(webclient.downloaddata("http://services.digg.com/2.0/story.gettopnews?type=rss"));     xmldoc.load(stream);       var mgr = new xmlnamespacemanager(xmldoc.nametable);     mgr.addnamespace("ns", "http://www.w3.org/2005/atom");       xmlnodelist xmlnode = xmldoc.selectnodes(xmlpath, mgr);      int count = xmlnode.count;      console.writeline("count : "+count);      //console.writeline(xmlnode.name + ": " + xmlnode.innertext);     console.readkey(); 

what i'am dogin wrong!?!? other problema i've how tag in different namespace

<digg:category> technology </digg:category> 

thaks

when call mgr.addnamespace("ns", "http://www.w3.org/2005/atom"), defines namespace prefix ns, can use in xpath query. but have use it:

var xmlpath = "/ns:feed/ns:entry"; 

although if you, use more descriptive prefix, atom, or a.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -