Hi all,

Perhaps I'm simply doing something wrong, but I can't seem to parse RSS 1.0.
I've included below the irb session to illustrate what I mean. Google results yielded nothing along these lines. Any help much appreciated, thanks in advance.

require 'xml/libxml'
    ==>true

# Lots of xml elided for clarity
doc = XML::Document.file('http://del.icio.us/rss/tag/ruby')
    ==><?xml version=" 1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns=" http://purl.org/rss/1.0/" xmlns:cc="http://web.resource.org/cc/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/ " xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/ " xmlns:admin="http://webns.net/mvcb/">

<channel rdf:about="http://del.icio.us/tag/ruby">
<title> del.icio.us/tag/ruby</title>
<link>http://del.icio.us/tag/ruby</link>
</channel>
</rdf:RDF>

# Lets inspect the relevant namespaces...
# RDF
rdf = doc.root.namespace[0]
    ==>rdf
rdf.prefix?
    ==>true
rdf.prefix
    ==>"rdf"
rdf.href
    ==>" http://www.w3.org/1999/02/22-rdf-syntax-ns#"

# RSS 1.0
rss = doc.root.namespace[1]
    ==>
rss.prefix?
    ==>false
rss.prefix
    ==>nil
rss.href
    ==>" http://purl.org/rss/1.0/"

# This works, but commented out for simplicity
# doc.find('//rdf:RDF')

# This doesn't work (and should)
doc.find('/rdf:RDF/channel/title').to_a
    ==>[]

# Neither does this (and should)
doc.find('//title').to_a
    ==>[]

# Or this (and should)
doc.root.find('//title').to_a
    ==>[]


--
Best Regards,
Christian Romney
_______________________________________________
libxml-devel mailing list
libxml-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel

Reply via email to