Home » Core Java » xml » XPath (page 3)

XPath

XPath concat Example

We studied about Xpath normalize-space() method in the previous example. In this example, we will study how the concat(String s1, String s2, String... s3) method works. The XPath-concat method works similar to the String#concat method. It joins two or more strings into a single string. The argument strings maybe two or more static strings and/or they may be two or ...

Read More »

XPath normalize-space example

In this example, we will talk about the normalize-space method in XPath. The normalize-space(String s) method is used to normalize a string i.e. to remove any leading or trailing spaces from the string s passed as parameter to the XPath function. We will look at a few examples at the examples to see how the normalize-space method works in an ...

Read More »

XPath substring example

In this example, we will try to see how we can use the sub-string method in the XPath for our use-cases. The sub-string method is used to search for the sub-string in the beginning or the end or anywhere in the XPath node. It can also be used to extract the part of the sub-string from the string by specifying ...

Read More »

XPath preceding-sibling example

In this example we will learn how to use the preceding-sibling 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 ‘preceding-sibling’ function. Tools and technologies used in this example are Java 1.7, Maven, Intellij. 1. Overview An XPath expression specifies a pattern ...

Read More »

XPath local-name example

Continuing on the series of examples about XPath, we will see how we can use the local-name function in Java. We use this XPath function we need to work with namespaces. What are namespaces? Namespaces are used to avoid conflicts in the tag-names. The tags have a prefix defined by the xmlns attribute(short for XML namespace).     Let’s see ...

Read More »

Using XPath in Selenium Example

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

Read More »

XPath following-sibling example

In this example we will learn how to use the following-sibling 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 ‘following-sibling’ function. Tools and technologies used in this example are Java 1.7, Maven, Intellij. 1. Overview An XPath expression specifies a pattern ...

Read More »

XPath String functions example

In the previous examples, we talked about how we can query for a particular node(s) and extract the attribute value from a node in an XML Document. In this example, we shall see what other String operations on XPath are supported by the Java programming language. The String operations are a range of functions that may be used to search/query. ...

Read More »

XPath starts-with example

In this example we will learn how to use starts-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 ‘starts-with’ function. Tools and technologies used in this example are Java 1.7, Maven, Intellij. 1. Overview XPath expression specifies a pattern that ...

Read More »

XPath get attribute value example

Continuing on our previous example on how to search for a text using XPath, we shall demonstrate how to get an attribute value from an XPath Node. As we already know, the @ attribute is used to denote an attribute in the XPathExpression. So we shall use extract the attribute value by specifying the node selector in the expression. In ...

Read More »