to the main page about the tutorial  THE XML REVOLUTION  -  TECHNOLOGIES FOR THE FUTURE WEB back up next

XPath examples

The following XPath expressions point to sets of nodes in the recipe collection:

"The amounts of flour being used":
//ingredient[@name="flour"]/@amount
4
0.5
3
0.25

"The ingredients of which half a cup are used":
//ingredient[@amount='0.5' and @unit='cup']/@name
grated Parmesan cheese
shredded mozzarella cheese
shortening
flour
orange juice

"The second step in preparing stock for Cailles en Sarcophages":
//ingredient[@name="stock"]/preparation/step[position()=2]/text()
When the liquid is relatively clear, add the carrots, celery, whole onion, 
bay leaf, parsley, peppercorns and salt. Reduce the heat, cover and let 
simmer at least 2 hours to make a hearty stock.

back COPYRIGHT © 2000-2003 ANDERS MØLLER & MICHAEL I. SCHWARTZBACH next