JAG

James Griffiths Ltd

Querying XML example

 

Information



Using XPATH to Query XML

The first example is processed on the server and the second on the client.


Please select a category to display. N.B. You can select more then one category, use 'ctrl' or 'shift' keys as you select.

        

When click the button the XML file will be queried for the categories selected by an XSLT file. The output from which will be displayed as HTML.


The next example queries XML  by testing to see if a condition is met (Location = Sheffield) and returns the records that match.

Query XML

 

Using XPATH

The selections you make are passed to ASP file which will call the XML and XSL files. The parameter is created from your selections and passed to the XSL file, e.g. "3, 5, 7", (the categories are passed using their IDs rather than their names).

The XSL file queries the XML with the following syntax (XPATH in blue).

<table>
<xsl:for-each select="//CategoryID
[(CategoryID = 20)]">
<tr>
<td>
<xsl:value-of select="Product">
</td>
</tr>
</xsl:for-each>
</table>