Introduction to: RDF vs XML

By on

There has always been a misconception between the relationship of RDF and XML. The main difference: XML is a syntax while RDF is a data model.

RDF has several syntaxes (Turtle, N3, etc) and XML is one of those (known as RDF/XML). Actually, RDF/XML is the only W3C standard syntax for RDF (Currently, there is Last Call on Turtle, a new W3C standard syntax for RDF). Therefore, comparing XML and RDF is like comparing apples with oranges. What can be compared is their data models. The RDF data model is a graph while the XML data model is a tree.

Comparing RDF with XML

Joshua Tauberer has an excellent comparison between RDF and XML, which I recommend. Two advantages of RDF are highlighted: flexibility of the data model and use of URIs as global unique identifiers.

Flexibility of the Data Model

There are different ways of representing data in XML. Consider representing “An iPhone is a Product that has a price of $200” The following would be valid XML:


Another valid XML could be:

<product title=”iPhone”>

Modeling this same data in RDF would only have one way of representing it:

ex:product1 rdf:type ex:Product .
ex:product1 ex:title “iPhone” .
ex:product1 ex:price “200” .

In a way, the tree data model of XML is too flexible: you can say what you want to say in so many different ways. In order to understand what the XML document is about, an application needs the DTD or the schema. RDF also has a schema, namely an ontology, represented in RDFS or OWL. The ontology adds the semantics to your data and even allows you to infer new information from your current data (XML can’t do this).

If an XML document is defined by a DTD or schema, it is not extensible. If you want to add new attributes to your XML, all the parties using the DTD or schema need to agree on the changes. You could stop using a DTD or Schema, and that would make XML completely flexible, but then the parties involved wouldn’t know what the data is about. In RDF, even with an ontology, you can still be flexible and add RDF triples. You can even add RDF triples that use terms from other ontologies. Let’s say I want to add the number of iPhones in stock, simply add the following triple:

ex:product1 ex:inStock “300” .

URIs as Global Unique Identifiers

Unique identifiers can be added in XML documents, however, they are unique within the document and not globally (in the world). RDF uses URIs which are universal global unique identifiers. If I want to retrieve information about the iPhone product, all I would need is to dereference the “ex:product1” URI. Mixing the graph data model with URIs, we have… Linked Data! Technically, linking between XML documents is possible with XLink, however it failed to gain adoption.


XML is a syntax and its data model is a tree. RDF is a data model based on a graph, that uses URIs and has several different syntax, including an XML syntax. Nevertheless, both XML and RDF can be used to represent structured data on the web and move data around between applications.

About the Author

Photo of Juan SequedaJuan Sequeda is a Ph.D student at the University of Texas at Austin and a NSF Graduate Research Fellow. His research is in the intersection of Semantic Web and Relational Databases. He co-created the Consuming Linked Data Workshop series and regularly gives talks at academic and industry semantic web conferences. Juan is an Invited Expert on the W3C RDB2RDF Working Group and an editor of the “Direct Mapping of Relational Data to RDF” specification. Juan is also the founder of a new startup, Capsenta, which is a spin-off from his research.

Leave a Reply