RDF and Xpath

Posted on 2006-05-25
Medium Priority
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 vb.net then that is also fine.

<?xml version="1.0" encoding="ISO-8859-1" ?>
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://purl.org/rss/1.0/">
  <channel rdf:about="http://education.guardian.co.uk/0,,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="http://image.guardian.co.uk/sitecrumbs/Guardian.gif" />
  <rdf:li resource="http://education.guardian.co.uk/policy/story/0,,1782657,00.html?gusrc=rss" />
  <rdf:li resource="http://education.guardian.co.uk/admissions/story/0,,1781877,00.html?gusrc=rss" />
  <rdf:li resource="http://education.guardian.co.uk/pupilbehaviour/story/0,,1781055,00.html?gusrc=rss" />
  <rdf:li resource="http://education.guardian.co.uk/higher/news/story/0,,1782731,00.html?gusrc=rss" />
  <rdf:li resource="http://education.guardian.co.uk/specialreports/lecturerspay/story/0,,1782020,00.html?gusrc=rss" />
  <rdf:li resource="http://education.guardian.co.uk/higher/news/story/0,,1782618,00.html?gusrc=rss" />
  <rdf:li resource="http://education.guardian.co.uk/higher/worldwide/story/0,,1781991,00.html?gusrc=rss" />
  <rdf:li resource="http://education.guardian.co.uk/higher/columnist/story/0,,1781413,00.html?gusrc=rss" />
  <rdf:li resource="http://education.guardian.co.uk/schools/columnist/story/0,,1780584,00.html?gusrc=rss" />
  <rdf:li resource="http://education.guardian.co.uk/higher/comment/story/0,,1780663,00.html?gusrc=rss" />
  <rdf:li resource="http://education.guardian.co.uk/universityguide2006/story/0,,1765251,00.html?gusrc=rss" />
  <rdf:li resource="http://education.guardian.co.uk/further/story/0,,1780643,00.html?gusrc=rss" />
  <rdf:li resource="http://education.guardian.co.uk/mba/story/0,,1779161,00.html?gusrc=rss" />
  <rdf:li resource="http://education.guardian.co.uk/students/housing/story/0,,1781233,00.html?gusrc=rss" />
  <rdf:li resource="http://education.guardian.co.uk/students/news/story/0,,1781332,00.html?gusrc=rss" />
  <image rdf:about="http://image.guardian.co.uk/sitecrumbs/Guardian.gif">
  <title>Education Guardian</title>
  <item rdf:about="http://education.guardian.co.uk/policy/story/0,,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="http://education.guardian.co.uk/admissions/story/0,,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

Accepted Solution

Klax earned 200 total points
ID: 16767451
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", "http://purl.org/rss/1.0/");

            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


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

864 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