Posts

Showing posts with the label xpath

XPath Query with XmlNode.SelectSingleNode

While trying to parse SBML biological models on my ASP.NET project, I faced with a strange behavior of Select method of XmlNode. In SBML, users have to define a namespace for the SBML version and level. However, in general for the remaining of the RDF file which defines species, reactions, etc., users do not use any namespace and rely on default namespace. Nonetheless, Select method of XmlNode needs a namespace to invoke a XPath query on RDF file. You need to define a namespace for your XmlDocument like the following; XPathDocument x = new XPathDocument(new StringReader(xmldoc.OuterXml)); XPathNavigator foo = x.CreateNavigator(); foo.MoveToFollowing(XPathNodeType.Element); // Add the namespace. var NSDICT = foo.GetNamespacesInScope(XmlNamespaceScope.All); var nsmgr = new XmlNamespaceManager(xmldoc.NameTable); foreach (KeyValuePair pair in NSDICT) { if (String.IsNullOrEm...

XPath and XQuery Processor Survey

Image
Introduction Once you have the data in hand, it is important to be able to query and serve it according to users' needs. By the development of internet huge data sources are created and started be exchanged between different web applications. Since XML is the popular, easy and structured way of exchanging data across web sites and applications, querying the XML data becomes a major issue. Therefore W3C[1] come up with solutions to this problem; XPath and XQuery are two of those querying languages that are defined by the groups in W3C. XPath is a subset of XQuery and XQuery uses the XPath expression syntax. In order to compile the code that is written in these languages, XPath and XQuery processors are developed. In this survey, we will discuss three XML processors and compare them. Saxon XSLT and XQuery Processor (Home Edition) Saxon[2] started as an XSLT 1.0 processor and only supported language was Java. After the release of XSLT 2.0 and XQuery 1.0, Saxon comes up with two diff...