Exercises for Lecture 2

XPath

  1. Run the recipe examples through the XPath Visualizer.

  2. Write an XPath expression that for each recipe that also uses milk, finds the number of eggs being used (the result is a list of numbers).

  3. Experiment with the position predicate using different axes, make sure you also try some reverse axes.

  4. Explain the result of the following XPath expression on recipes:

    //ingredient/ingredient/ingredient/ancestor::recipe[number(.//nutrition/@calories)>number(5000)]/title

  5. Use the XPath Visualizer on your own XML version of the weblog. Try out as many axes as possible.

Tips