如何从主题URINode查找谓词

时间:2017-09-21 09:31:15

标签: c# dotnetrdf rdf-xml

我不知道如何从主题URINode读取te谓词(URINodes)。

此外,是否有通过特定谓词值查找IURINode?

1 个答案:

答案 0 :(得分:1)

我似乎在this post找到了我所需的方法!

我的解决方案:

//Path to RDF/XML file
pathToRDF = "c:\dotNetRdfExample\exampleRDF.xml"

// A IGraph Parser, implementing the IRdfReader interface (So it can work with RDF/XML formats)
RdfXmlParser rxpparser = new RdfXmlParser();

// Create a graph for the rdf data
Graph g = new Graph();

// Makes sure that the XML file is UTF8
StreamReader sr = new StreamReader(pathToRDF, true);

// Fill the empty IGraph, using the rdfXmlParser
rxpparser.Load(g, sr);

// Retrieve all triples with the specified predicate and object
IEnumerable<Triple> specificTriples = g.GetTriplesWithPredicateObject(g.CreateUriNode(UriFactory.Create("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")), 
        g.CreateUriNode(UriFactory.Create("http://www.projectenportfolio.nl/wiki/index.php/Speciaal:URIResolver/Category-3AHandelingsperspectief")));