|
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlDocument xmlDocBody = new System.Xml.XmlDocument();
// load an individual subject heading
xmlDoc.Load("http://id.loc.gov/authorities/sh95000541#concept");
MessageBox.Show(xmlDoc.OuterXml.ToString());
/*
Process the downloaded Subject Headings (i.e. the decompressed RDF/XML file)
* Note: the structure of a description node is as follows
<rdf:Description rdf:about="http://id.loc.gov/authorities/sh85120352#concept" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<dcterms:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime" xmlns:dcterms="http://purl.org/dc/terms/">1986-02-11T00:00:00-04:00</dcterms:created>
<skos:inScheme rdf:resource="http://id.loc.gov/authorities#conceptScheme" xmlns:skos="http://www.w3.org/2004/02/skos/core#" />
<skos:inScheme rdf:resource="http://id.loc.gov/authorities#topicalTerms" xmlns:skos="http://www.w3.org/2004/02/skos/core#" />
<rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept" />
<skos:related rdf:resource="http://id.loc.gov/authorities/sh85076763#concept" xmlns:skos="http://www.w3.org/2004/02/skos/core#" />
<skos:prefLabel xml:lang="en" xmlns:skos="http://www.w3.org/2004/02/skos/core#">Service industries--Taxation</skos:prefLabel>
<owl:sameAs rdf:resource="info:lc/authorities/sh85120352" xmlns:owl="http://www.w3.org/2002/07/owl#" />
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime" xmlns:dcterms="http://purl.org/dc/terms/">1986-02-11T00:00:00-04:00</dcterms:modified>
</rdf:Description>
*/
// load the subject headings into an XML Document
xmlDocBody.Load(@"C:\20090604_164455.rdf");
//create a name space manager so that the XML document can be processed by XPath
XmlNamespaceManager nsMgr = new XmlNamespaceManager(new NameTable());
nsMgr.AddNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
nsMgr.AddNamespace("skos", "http://www.w3.org/2004/02/skos/core#");
nsMgr.AddNamespace("dcterms", "http://purl.org/dc/terms/");
nsMgr.AddNamespace("owl", "http://www.w3.org/2002/07/owl#");
nsMgr.AddNamespace("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
nsMgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema#");
// get the first rdf:Description node
System.Xml.XmlNode nodeDescription = xmlDocBody.SelectSingleNode("//rdf:Description", nsMgr);
int i = 0;
// iterate thru all of the remaining rdf:Description nodes
while (nodeDescription != null)
{
i++;
string aboutURL = nodeDescription.Attributes.GetNamedItem("rdf:about").Value;
string label = nodeDescription.SelectSingleNode("skos:prefLabel", nsMgr).InnerText;
nodeDescription = nodeDescription.NextSibling;
}
MessageBox.Show("There were " + i.ToString() + " rdf:Description nodes");
Application.Exit();
|