A Look At XPath

10 views
Skip to first unread message

jenny wilkinson

unread,
Feb 11, 2013, 7:35:42 AM2/11/13
to
XPath is a query language currently in use in XML to query and also pick out nodes from an XML document. The truth is, it's also possible to utilize it to determine values, like strings, numbers and Bolean values) with the content of any XML document.

XPath is exceedingly flexible and as such you can make use of it along with other standards beyond XML, for example XSLT and XPointer. Using XSLT there is the ability to develop one XML document around the back of another XML document, and even develop a XHTML document which can be read and seen by the bare human eye.

But exactly how does XPath operate exactly? To be really exact, it works by pointing to the XML dataset, therefore have to access the DOM and not the actual characters that are in the XML tag. So due to this, so that you can process with XPath, you need a document format that will produce a DOM or similar dataset, for instance XML or JSON.

Most of all, you can utilize a location path syntax, which you'll do in a few methods. A single '/' at the start of an area path signifies the document node, the only child of which is the root element. If a location path starts off with a '/' (thus from the document node), it is an absolute location path, otherwise it is a relative location path.

When working with XPath to produce your search queries, you may use a number of parameters or queries.

One such parameter is Predicate (the part that is inside the square brackets), which you can use to filter results and will include any expression. If the result is not empty, its regarded as true, and if it is empty then its regarded false. If the result is a number value, that numeric value signifies the proximity of the position of the node.

From the proximity position, you now have a forward and reverse axis. The forward axis is one where all the nodes come after the context node, like child etc. The Reverse axis is the opposite, i.e. the nodes arrive ahead of the context node, like parent etc.

There's also quite a few crucial functions that happen to be employed in Xpath, such as position() and last(). Last() will return the final position inside your current node selection and position() will return the position of a node in your selection.

More information on XPath is available at W3C schools you can also refer to this http://www.liquid-technologies.com/xpath-tutorial.aspx (XPath tutorial).













Reply all
Reply to author
Forward
0 new messages