title: how to parse RDF/XML using rdflib.js or rdf-parser-rdfxml in Node.js
body: <p>I am trying to read an rdf/xml file and parse it possibly in JSON or JavaScript Object or any other format. I try to search a lot of node libraries but couldn't find any good example to do so. All the have provide some API without proper documentation( Or they gave but I didn't understand properly). Here is something I have tried.</p>
  
  <pre><code>var fs = require('fs'),
  rdfParser = require('rdf-parser-rdfxml');
  
  var res=rdfParser(__dirname+'/1.xml');
  console.log(res);
  </code></pre>
  
  <p>here is 1.xml file</p>
  
  <pre><code>&lt;rdf:RDF
      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      xmlns:oneM2M="http://www.onem2m.org/ontology/Base_Ontology#"
      xmlns:owl="http://www.w3.org/2002/07/owl#"
      xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
      xmlns:cfso="http://203.254.173.81:8080/ontologies/ConnectedFarmServiceOntology.owl#"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema#"&gt;
    &lt;oneM2M:Thing rdf:about="http://203.254.173.81:8080/ontologies/ConnectedFarmServiceOntology.owl#KETICF"&gt;
      &lt;cfso:hasSpecies&gt;
        &lt;cfso:Species rdf:about="http://203.254.173.81:8080/ontologies/ConnectedFarmServiceOntology.owl#Type1"/&gt;
      &lt;/cfso:hasSpecies&gt;
      &lt;cfso:hasSPName&gt;
        &lt;cfso:SPName rdf:about="http://203.254.173.81:8080/ontologies/ConnectedFarmServiceOntology.owl#Maxfor"/&gt;
      &lt;/cfso:hasSPName&gt;
      &lt;cfso:hasLocation&gt;
        &lt;cfso:Location rdf:about="http://203.254.173.81:8080/ontologies/ConnectedFarmServiceOntology.owl#Buyeo"/&gt;
      &lt;/cfso:hasLocation&gt;
      &lt;cfso:hasCropName&gt;
        &lt;cfso:CropName rdf:about="http://203.254.173.81:8080/ontologies/ConnectedFarmServiceOntology.owl#CharryTomato"&gt;
          &lt;cfso:hasSpecies rdf:resource="http://203.254.173.81:8080/ontologies/ConnectedFarmServiceOntology.owl#Type1"/&gt;
        &lt;/cfso:CropName&gt;
      &lt;/cfso:hasCropName&gt;
      &lt;cfso:hasControlMode&gt;
        &lt;cfso:ControlMode rdf:about="http://203.254.173.81:8080/ontologies/ConnectedFarmServiceOntology.owl#A"/&gt;
      &lt;/cfso:hasControlMode&gt;
    &lt;/oneM2M:Thing&gt;
  &lt;/rdf:RDF&gt;
  </code></pre>
  
  <p>I have also tried with rdflib.js in pretty much similar way. </p>
  
  <pre><code>var fs = require('fs'),
      $rdf = require('rdflib');
  
  //var parser = new xml2js.Parser();
  fs.readFile(__dirname + '/1.xml', function(err, data) {
      // Fetch data via a regular AJAX call, load from a file, or pass in a literal
      // string. In this example, it was loaded from 'https://fred.me/profile'
      var store = $rdf.graph()  // Init a new empty graph
      var contentType = 'application/rdf+xml'
      var baseUrl = ""
      var parsedGraph = $rdf.parse(data, store, baseUrl, contentType);
  
      $rdf.parse(data,function(triples){
          for (var i in triples){
              console.log(triples[i]);
          }
      })
  });
  </code></pre>
  
  <p>Help me out someone :) Thanx in advance</p>