Search code examples
c#dotnetrdfrdf-xml

How to lookup predicates from a subject URINode


I don't realy understand how to read te predicates (URINodes) from a subject URINode.

Also, is there anyway to lookup IURINodes by specific predicates values?


Solution

  • I seem to have found my required methode on this post!

    My solution:

    //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")));