如何从主题 URINode 中查找谓词
How to lookup predicates from a subject URINode
我真的不明白如何从主题 URINode 读取谓词 (URINodes)。
此外,是否可以通过特定谓词值查找 IURINode?
我似乎在 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")));
我真的不明白如何从主题 URINode 读取谓词 (URINodes)。
此外,是否可以通过特定谓词值查找 IURINode?
我似乎在 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")));