Home » Core Java » xml » Page 3

xml

XPath innertext selection example

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. 1. Overview An XPath expression ...

Read More »

XPath count example

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 ...

Read More »

XPath ends-with example

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. 1. Overview An XPath expression specifies a pattern ...

Read More »

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 »