Tag Archives: XPATH

XPath parent node example


via XPath parent node example | Examples Java Code Geeks.

In the previous example, we introduced the dependant axis specifier. In this example, we shall talk about the ancestor axis in XPath Expression.

The ancestor tag is used to select the ancestor of the current node and the ancestor of the ancestor and so on in context of the current node.

We will look at a few examples to see how ancestor works.

Consider the XML file below for our example. The File has a number of nodes under the tag representing a cricket team:

cricketTeam_info.xml

XPath ancestor example


via XPath ancestor example | Examples Java Code Geeks.

In this example we will learn how to get the ancestor details of a given node using XPath. We will start with the introduction of XPath – what it is and how to use it, then we will see the working model of the desired functionality.

Tools and technologies used in this example are Java 1.6, Maven, Intellij.(Please note you don’t need Maven to run this example. It can be run as standalone java application. You can use any IDE or even not use any if you want to.)

XPath descendant example


via XPath descendant example | Examples Java Code Geeks.

In this example we shall talk about the Descendant axis specifier in XPath. An axis specifier indicates the direction of navigation in DOM tree of that XML document. This helps in effectively querying the XML document.

The Descendant axis selects all the descendants of the current node. The ‘descendant’ refers to the children and grand-children of the current node.

We will look at a few examples to see how descendant works.

Consider the XML file below for our example. The File has a number of <cricketer> nodes under the <cricketers> tag representing a cricket team:

cricketTeam_info.xml

XPath innertext selection example


via XPath innertext selection example | Examples Java Code Geeks.

In this example we will learn how to select a node with a given inner text using XPath. We will start with the introduction of XPath – what it is and how to use it, then we will see the working model of inner-text selection. Tools and technologies used in this example are Java 1.6, Intellij.

Web scraper for NodeJS


via rc0x03/node-osmosis · GitHub.

Features

  • Fast: uses libxml C bindings
  • Lightweight: no dependencies like jQuery, cheerio, or jsdom
  • Clean: promise based interface- no more nested callbacks
  • Flexible: supports both CSS and XPath selectors
  • Predictable: same input, same output, same order
  • Detailed logging for every step
  • Precise and natural IO flow- no setTimeout or process.nextTick
  • Easy debugging with built-in stack size and memory usage reporting
  • Memory leak free

XPath count example


via XPath count example | Examples Java Code Geeks.

In the previous example, we studied how to use the XPath Concat method. In this example, we will see how to use the count method in XPath.

The XPath count() method is used to count the number of nodes matching a given XpathExpression.

Let’s look at a few examples to understand how the count method works. Consider the XML file below for our examples:

XPath ends-with example


via XPath ends-with example | Examples Java Code Geeks.

In this example we will learn how to use the ends-with function of XPath. We will start with the introduction of XPath – what it is and how to use it, then we will see the working model of ends-with function.
Tools and technologies used in this example are Java 1.7, Maven, Intellij, Saxon.