开发者

Writing RDF/XML file from rdf Triples in rdflib

开发者 https://www.devze.com 2023-03-09 01:25 出处:网络
I have got rdf triples with me, now I am interested in ge开发者_开发百科nerating RDF/XML file using rdflib in Python. Could you please give me some sample code to start.

I have got rdf triples with me, now I am interested in ge开发者_开发百科nerating RDF/XML file using rdflib in Python. Could you please give me some sample code to start.

Thanks


The rdflib docs could be a good starting point, particularly the Getting Started section. For example:

import rdflib
from rdflib.Graph import Graph
g = Graph()
g.parse("http://www.w3.org/2000/10/rdf-tests/rdfcore/ntriples/test.nt", 
        format="nt")
g.serialize("test.rdf", format="rdf/xml")


If rdf/xml format is unknown (depends on the version of rdflib), use instead:

g.serialize("test.rdf", format="pretty-xml")
0

精彩评论

暂无评论...
验证码 换一张
取 消