how to read custom element from RSSFeed XML

I want to read data from a XMl file which is in a predefined format as given

<?xml version="1.0"
 <rss version="2.0" xmlns:Poll="">
 <title>Please Enter Title</title>
 <category>Please Enter Today's Voting Poll</category>
<description>Please Enter Description</description>
<lastBuildDate>Fri, 09 Mar 2012 10:30:55 UT</lastBuildDate>
  <title>Topic Title</title>
  <Poll:ID>Poll Id</Poll:ID>

I an not able to read data that has Poll in the prefix of the element tag.

foreach (XmlNode RSSNode in RSSChannelItemList)
            XmlNode RSSSubNode;
            RSSSubNode = RSSNode.SelectSingleNode("title");
            string title = RSSSubNode != null ? RSSSubNode.InnerText : "";
            XNamespace Tips = "";
            RSSSubNode = RSSNode.SelectSingleNode("ID");
            string link = RSSSubNode != null ? RSSSubNode.InnerText : "";
            link = RSSSubNode!=null ? RSSSubNode.InnerXml : "";

I get the title value perfectly but I am unable to get the value of ID This is a custom tag in the XMl

Can anyone suggest me How to do this?

Last updated:9/3/2014 11:30:00 PM

1 Answers

Sumit Kesarwani
Sumit Kesarwani

Hi Chintoo, 

try this:

XmlNamespaceManager nameSpace = new XmlNamespaceManager(doc.NameTable);

     nameSpace.AddNamespace('Tips', '');

     RSSSubNode = RSSNode.SelectSingleNode('Tips:ID',nameSpace);

     string link = RSSSubNode != null ? RSSSubNode.InnerText : '';