Feed on
Subscription

XPath - Predicates

We have learned how to select elements and attributes in an XML document, but we haven't learned how to be eliminate unwanted items. This lesson will teach you how to impose restrictions in your XPath expressions using predicates.

We will be using our lemonade2.xml file, which you can download.
...

XPath - Vertical Bar | (Pipe)

XPath makes use of the character "|", which we will be referring to as pipe from here on out. The pipe character is a way of combining two or more expressions into one. Depending on where you are using XPath, this ability to combine multiple expressions into one may be useful.
...

XPath - Wildcard *

A wildcard is a special character used in programming to include everything in your selection. Up to this point we have been specifying elements by their name, but with the use of the wildcard * we can actually select more than one element at a time.
...

XPath - Parent ..

This lesson will teach you how to select the parent of an element in your XPath expressions.

We will be using our lemonade2.xml file, which you can download.

XML Code, lemonade2.xml:



$2.50...

XPath - Descendants "//"

As you know, the slash "/" is used to separate parent from child in our XPath expressions. However, when you put two slashes together "//", it does something completely different. Two slashes are used to select the descendants of an element.

This lesson will teach you how to advance your XPath knowledge and save time with the descendant double-slash "//".
...

XPath - Relative Location

Now for something completely different! XPath expressions can also be created using relative location paths. Instead of starting at the root element, you can simply reference the element you want and go from there.

We will be using our lemonade2.xml file, which you can download.
...

XPath - Absolute Location

Up to this point, we have been selecting elements by giving the full path. We start with the the root element and end with the desired descendant element. This method of using the complete path is referred to as absolute location path, and it is useful for selecting a specific element.
...

XPath - Attribute

You have already learned how to select any element in an XML document, but how would you get that element's attribute? Those attributes values are within your reach once you learn how to use @ !

We will be using our lemonade2.xml file, which you can download.
...

XPath - Element

The most common usage of XPath is for selecting elements in an XML document. This lesson will provide a walkthrough of selecting many different elements, at different levels, in the XML Tree.

We will be using our lemonade2.xml file, which you can download. Below is the contents of lemonade2.
...

XPath - Expressions

XPath can locate any type of information in an XML document with one line of code. These one liners are referred to as "expressions," and every piece of XPath that you write will be an expression. Just to make it crystal clear, here's the definition of an expression as it relates to our usage.
...
« 1 2 3 »