XPath - Part 3: Filtering with Static Values


To filter data based on a single, static criteria through the creation of a simple document which displays a list of products shipped by a specified shipper.

Background Information

Now, we’re working with some data, we’re able to arrange it a little bit with the orderby feature we learned in the second XPath tutorial. What if we only want to see the products shipped by shipper 1? That’s exactly what filters are used for and we’ll learn how to do that in this tutorial. The next tutorial will teach you how to do the same thing with a more dynamic value (using variables).


Inserting a Tag, ForEach Tag, XPath - Part 1: Basic Selection, XPath - Part 2: Sorting with Orderby

Starting Template

This tutorial is a continuation of the XPath - Part 2: Sorting with OrderBy tutorial. If you haven’t completed that tutorial yet, you should go back and do it first, then start here with the template leftover at the end of Part 2.


1. Open XPath Wizard

Start off by selecting the [forEach Order: tag and click the Wizard button as you have done in the previous tutorials, in order to open the XPath Wizard.

Show Me How!

2. Add a group, then add a condition

In order to create a filter, we need to add a filter group, where we can then set a condition for the filter. Click the appropriate statements to do so.

Show Me How!

3. Set node to ShipVia

In the condition, there are left and right side values, the left is a field of your data, and the right is a value you test against. In the middle, it lets you select what type of comparison will be made. We’re going to set the left side to the ShipVia node, and we’ll leave the middle at equal to.

Show Me How!

4. Set value to 1

On the right side, we set a value to compare against. In this tutorial we are simply setting a static value here, so into the right side, set the value to 1. In the next tutorial, we’ll show you how to use a variable here instead.

Show Me How!

5. Generate and view results

Now, as you always do, close the wizard, generate the document and view the results!

Show Me How!

Quiz Yourself!

True/False: Filtering is simply a way of getting rid of nodes I don’t need, so I only get a small number of nodes to choose from.
False. Filtering is actually used to select data entities that match a set of conditions, and return all sibling nodes, not specific nodes themselves.
True. That’s the point of the XPath Wizard
True. Filtering can filter anyway you want; nodes, children, attributes, anything.
False. Filtering removes the good stuff from my data so all I’m left with is junk.
Can you use drag and drop to create filter?
No. The XPath Wizard has a more intuitive interface which uses plain English to direct your actions.
Yes. The Wizard can do anything! You can even drag n’ drop data from Mars to Earth!
No, you have to click the links first, then you can drag n’ drop.
Yes. But I’m not sure what to drag so I just click.
What is not a good use for filters?
Finding data based on criteria that is not stored in the database
Like online shopping, I want something that costs less than X, and is made by brand Y
Selecting a subset of financial data based on a certain date range
Creating a book list with books only written by a certain author.


You have completed this tutorial. We recommend taking a look at the XPath - Part 4: Filtering with Parameter Values tutorial next!