O'Reilly logo

Content Syndication with RSS by Ben Hammersley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

RDF in XML

In preparation for Chapter 6, we need to look at how RDF is written in XML.

The Root Element

In all the examples in this book, I have given the RDF attributes a prefix of rdf:. This is not necessary in many RDF documents, but it is the way they appear in RSS 1.0. For the sake of clarity, we will leave them in here too. Therefore, for reasons we will discuss in Chapter 6, the root element of an RDF document is:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
. . .
</rdf:RDF>

As we will see in Chapter 6, the root element can also contain the URIs of additional RDF vocabularies. In the following examples, we will use elements from the RSS 1.0 vocabulary.

<element rdf:about="URI OF ELEMENT">

The rdf:about attribute defines the URI for the element that contains it. Remember, it is like the subject in a sentence—everything else refers to it. For example:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns="http://purl.org/rss/1.0/"
>
<channel rdf:about="http://www.example.org/">
. . .
</channel>
</rdf:RDF>

means the channel resource is identified by the URI http://www.example.org/. Or, more to the point, everything within the channel element is referred to by http://www.example.org.

The contents of the element then describe the object referred to by the URI:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
         xmlns="http://purl.org/rss/1.0/" >
<channel rdf:about="http://www.example.org">
<title>Sausages are tasty for breakfast</title> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required