467,076 Members | 985 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,076 developers. It's quick & easy.

Getting feed from rss 1.0

ru
Hello,

I'm trying to parse a rss 1.0 docoment like the following example from
http://www.instapundit.com:

<?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:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:cc="http://web.resource.org/cc/"
xmlns="http://purl.org/rss/1.0/">
- <channel rdf:about="http://www.instapundit.com/">
<title>Instapundit.com</title>
<link>http://www.instapundit.com/</link>
<description />
<dc:language>en-us</dc:language>
<dc:creator />
<dc:date>2003-09-28T22:39:45-05:00</dc:date>
<admin:generatorAgent
rdf:resource="http://www.movabletype.org/?v=2.64" />
- <items>
+ <rdf:Seq>
<rdf:li
rdf:resource="http://www.instapundit.com/archives/011739.php" />
</rdf:Seq>
</items>
</channel>
- <item rdf:about="http://www.instapundit.com/archives/011739.php">
<title />
<link>http://www.instapundit.com/archives/011739.php</link>
<description>JETBLUE PASSENGERS are unhappy about it sharing their
personal data. Interestingly, Wesley Clark is on the board of Acxiom,
the company involved, according to this story in the Post. Clark
didn't have a specific role with JetBlue, it says, but he was behind
the development of the passenger-information database
involved....</description>
<dc:subject />
<dc:creator>Glenn Reynolds</dc:creator>
<dc:date>2003-09-28T22:39:45-05:00</dc:date>
</item>
-</rdf:RDF>

Here's part of my code:

Dim NSM As New XmlNamespaceManager(XmlDoc.NameTable)

' Attempt to get any additional namespace information from
' the feed document.
Dim URI As String =
XmlDoc.DocumentElement.ChildNodes(0).NamespaceURI

If URI <> "" Then
NSM.AddNamespace("foo", URI)
strXPath = "//foo:item"
strTitle = "foo:title"
strDesc = "foo:description"
strLink = "foo:link"
strPubDate = "foo:dc:date"

End If

I can get to the link allright like so:
dim LinkData as string = XmlNode.SelectSingleNode(strLink,
NSM).InnerText

I'm having trouble getting data out of the title and date nodes. The
title.innertext returns an empty string if I try this:
Dim sss As String = oXmlNode.SelectSingleNode(sTitle, oNSM).InnerText
I propably do have to reference the <rdf:Seq> list, but how do I do
that?

And in trying to get data from the date-node like this:
Dim q As String = XmlNode.SelectSingleNode(strPubDate).InnerText
I get an XPathException: 'foo:dc:date' has an invalid token.

Thanks

Nov 11 '05 #1
  • viewed: 2253
Share:
1 Reply
lots of examples at
http://www.gotdotnet.com/community/u...aspx?query=rss
--
Dino Chiesa
Microsoft Developer Division
d i n o c h @ O N L I N E . m i c r o s o f t . c o m
"ru" <ur@sx3all.be> wrote in message
news:e4********************************@4ax.com...
Hello,

I'm trying to parse a rss 1.0 docoment like the following example from
http://www.instapundit.com:

<?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:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:cc="http://web.resource.org/cc/"
xmlns="http://purl.org/rss/1.0/">
- <channel rdf:about="http://www.instapundit.com/">
<title>Instapundit.com</title>
<link>http://www.instapundit.com/</link>
<description />
<dc:language>en-us</dc:language>
<dc:creator />
<dc:date>2003-09-28T22:39:45-05:00</dc:date>
<admin:generatorAgent
rdf:resource="http://www.movabletype.org/?v=2.64" />
- <items>
+ <rdf:Seq>
<rdf:li
rdf:resource="http://www.instapundit.com/archives/011739.php" />
</rdf:Seq>
</items>
</channel>
- <item rdf:about="http://www.instapundit.com/archives/011739.php">
<title />
<link>http://www.instapundit.com/archives/011739.php</link>
<description>JETBLUE PASSENGERS are unhappy about it sharing their
personal data. Interestingly, Wesley Clark is on the board of Acxiom,
the company involved, according to this story in the Post. Clark
didn't have a specific role with JetBlue, it says, but he was behind
the development of the passenger-information database
involved....</description>
<dc:subject />
<dc:creator>Glenn Reynolds</dc:creator>
<dc:date>2003-09-28T22:39:45-05:00</dc:date>
</item>
-</rdf:RDF>

Here's part of my code:

Dim NSM As New XmlNamespaceManager(XmlDoc.NameTable)

' Attempt to get any additional namespace information from
' the feed document.
Dim URI As String =
XmlDoc.DocumentElement.ChildNodes(0).NamespaceURI

If URI <> "" Then
NSM.AddNamespace("foo", URI)
strXPath = "//foo:item"
strTitle = "foo:title"
strDesc = "foo:description"
strLink = "foo:link"
strPubDate = "foo:dc:date"

End If

I can get to the link allright like so:
dim LinkData as string = XmlNode.SelectSingleNode(strLink,
NSM).InnerText

I'm having trouble getting data out of the title and date nodes. The
title.innertext returns an empty string if I try this:
Dim sss As String = oXmlNode.SelectSingleNode(sTitle, oNSM).InnerText
I propably do have to reference the <rdf:Seq> list, but how do I do
that?

And in trying to get data from the date-node like this:
Dim q As String = XmlNode.SelectSingleNode(strPubDate).InnerText
I get an XPathException: 'foo:dc:date' has an invalid token.

Thanks

Nov 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Brady Love | last post: by
1 post views Thread by Steve | last post: by
6 posts views Thread by affiliateian@gmail.com | last post: by
4 posts views Thread by Florian Lindner | last post: by
5 posts views Thread by Ed Flecko | last post: by
5 posts views Thread by jerry@mynetserv.com | last post: by
4 posts views Thread by Blake Garner | last post: by
reply views Thread by jakecjacobson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.