Home > DeveloperSection > Forums > how to read custom element from RSSFeed XML
Chintoo Semi

Total Post:135

Posted on    September-02-2014 11:42 PM


 1 Reply(s)
 811  View(s)
Rate this:

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

<?xml version="1.0" encoding="utf-8"?>

 <rss version="2.0" xmlns:Poll="http://www.example.com">


 <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 = "http://www.example.com";

            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?

Sumit Kesarwani

Total Post:378

Posted on    September-03-2014 11:30 PM

Hi Chintoo, 

try this:

XmlNamespaceManager nameSpace = new XmlNamespaceManager(doc.NameTable);

     nameSpace.AddNamespace("Tips", "http://www.example.com");

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

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

Don't want to miss updates? Please click the below button!

Follow MindStick