RDF::Microdata reader/writer

Microdata parser for RDF.rb.

Gem Version Build Status


RDF::Microdata is a Microdata reader for Ruby using the RDF.rb library suite.


RDF::Microdata parses Microdata into statements or triples using the rules defined in Microdata RDF.

Install with ‘gem install rdf-microdata’

Living implementation

Microdata to RDF transformation is undergoing active development. This implementation attempts to be up-to-date as of the time of release, and is being used in developing the Microdata RDF specification.

This implementation includes support for the proposed @itemprop-reverse attribute.

Microdata Registry

The parser uses a build-in version of the Microdata RDF registry.


Reading RDF data in the Microdata format

require 'rdf/microdata'
graph = RDF::Graph.load("etc/doap.html", format: :microdata)

Reading using content-negotation

require 'rdf/microdata'
graph = RDF::Graph.load("etc/doap.html", content_type: "text/html")


This spec is based on the W3C HTML Data Task Force specification and does not support GRDDL-type triple generation, such as for html>head>title anchor tags.

If the RDFa parser is available, {RDF::Microdata::Format} will not assert content type text/html or file extension .html, as this is also asserted by RDFa. Instead, the RDFa reader will invoke the microdata reader if an @itemscope attribute is detected.



Full documentation available on Rubydoc.info

Principle Classes

RDFa-based Reader

There is an experimental reader based on transforming Microdata to RDFa within the DOM. To invoke this, add the rdfa: true option to the {RDF::Microdata::Reader.new}, or use {RDF::Microdata::RdfaReader} directly.

The reader exposes a #rdfa method, which can be used to retrieve the transformed HTML+RDFa





This is free and unencumbered public domain software. For more information, see https://unlicense.org/ or the accompanying {file:UNLICENSE} file.