RDF and Xpath

Posted on 2006-05-25
Last Modified: 2013-11-18
Can anyone tell me how to get the title node of the channel of this rdf feed using xpath? (I have tried and tried and tried but the node keeps on getting returned as null!) I am using c# and .net 2.0 but if the answer is in then that is also fine.

<?xml version="1.0" encoding="ISO-8859-1" ?>
  <rdf:RDF xmlns:rdf="" xmlns:dc="" xmlns="">
  <channel rdf:about=",,472384,00.html?gusrc=rss">
  <title>Education Guardian</title>
  <description>The latest Education news from Guardian Unlimited.</description>
  <dc:publisher>Guardian Unlimited</dc:publisher>
  <dc:rights>Copyright © Guardian Unlimited</dc:rights>
  <image rdf:resource="" />
  <rdf:li resource=",,1782657,00.html?gusrc=rss" />
  <rdf:li resource=",,1781877,00.html?gusrc=rss" />
  <rdf:li resource=",,1781055,00.html?gusrc=rss" />
  <rdf:li resource=",,1782731,00.html?gusrc=rss" />
  <rdf:li resource=",,1782020,00.html?gusrc=rss" />
  <rdf:li resource=",,1782618,00.html?gusrc=rss" />
  <rdf:li resource=",,1781991,00.html?gusrc=rss" />
  <rdf:li resource=",,1781413,00.html?gusrc=rss" />
  <rdf:li resource=",,1780584,00.html?gusrc=rss" />
  <rdf:li resource=",,1780663,00.html?gusrc=rss" />
  <rdf:li resource=",,1765251,00.html?gusrc=rss" />
  <rdf:li resource=",,1780643,00.html?gusrc=rss" />
  <rdf:li resource=",,1779161,00.html?gusrc=rss" />
  <rdf:li resource=",,1781233,00.html?gusrc=rss" />
  <rdf:li resource=",,1781332,00.html?gusrc=rss" />
  <image rdf:about="">
  <title>Education Guardian</title>
  <item rdf:about=",,1782657,00.html?gusrc=rss">
  <title>Reforms must continue, Johnson insists</title>
  <description>Education secretary to warn that Labour must push ahead with public service reform despite damaging revolt over schools bill.</description>
  <item rdf:about=",,1781877,00.html?gusrc=rss">
  <title>Tories back calls to open up independent schools</title>
  <description>The Conservatives have backed fresh calls to open up independent schools to all bright children.</description>
Question by:coolblue2000
    1 Comment
    LVL 1

    Accepted Solution

    using System;
    using System.Collections.Generic;
    using System.Xml.XPath;
    using System.Xml;
    using System.Text;

    namespace ConsoleApplication1
        class Program
            static void Main(string[] args)

                XmlDocument doc = new XmlDocument();

                XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable);
                ns.AddNamespace("demo", "");

                XmlNodeList titles = doc.SelectNodes("//demo:title", ns);

                foreach (XmlNode node in titles)
                    Console.WriteLine("Node {0} = {1}", node.Name, node.InnerText);


    This should do the trick!



    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now