Text file Filter and Formatter -

XPath Search Example



This page gives one example of using the application to search for a particular XML path description, with certain conditions included. The following figures show one example involving the included search and query evaluation features. This is only an illustrative example using the XML-based menu document of the other examples.

 

It is possible to search through specific XML paths to try and find certain elements containing certain information. The application can filter text in a way that is similar to what an XPath query would do. You can specify the element tag names in the path to look for and then filter them accordingly, until only the relevant ones remain. In this example, based on the menu document, a user is searching for food related to waffles that is less than $8.00 in price. Note that there could be different ways to do this, but this example illustrates a number of simple features that allow an XML document to be traversed manually.

The first step is to find all of the food item names, or all elements with the 'name' tag:


 

We only want the waffle foods, so a query can be performed to filter the selected lines, to make sure that they contain the word 'waffles'. The query form is shown above and the result of the query is shown below:

 

 

Now only three named items are selected. With this application you now have a toolbar button to move all of the selected lines down one line automatically. This is the red downwards pointing arrow button. Clicking this results in the following lines being selected:

 

 

The search now needs to include only items that cost less than $6.00. The query form is again also shown, and executing this on the numerical element values results in one remaining, as shown below:

 

 

Finally, the user can move to the next element in this path, to retrieve the description of the food item, as shown in the final figure:

 

 

If desired, this text can then be saved, with the rest of the document removed. So this is something similar to asking a query to find the XML path 'name/price/description' with the conditions that the name value must contain 'waffles' and the price value must be less than $6.00.