这是我的 XML
<?xml version="1.0" encoding="ISO8859-1" ?>
<!-- modified from http://www.xmlfiles.com/examples/simple.xml -->
<_breakfastmenu>
<food type="vegetarian">
<name>Belgian Waffles</name>
<price>5.95</price>
<description>two of our famous Belgian Waffles with plenty of real maple syrup</description>
<calories>650</calories>
</food>
<food type="vegetarian">
<name>Strawberry Belgian Waffles</name>
<price>7.95</price>
<description>light Belgian waffles covered with strawberries and whipped cream</description>
<calories>900</calories>
</food>
<food type="vegetarian">
<name>Berry-Berry Belgian Waffles</name>
<price>8.95</price>
<description>light Belgian waffles covered with an assortment of fresh berries and whipped cream</description>
<calories>900</calories>
</food>
<food type="vegetarian">
<name>French Toast</name>
<price>4.50 </price>
<description>thick slices made from our homemade sourdough bread</description>
<calories>600</calories>
</food>
</_breakfastmenu>
我想找到所有包含“Waffles”的食物元素,我可以通过运行这个 XPath 成功地做到这一点:
_breakfastmenu/food/name[contains(text(), "Waffles")]
但我也想知道这些的价格,正确的方法是什么,我尝试了一段时间没有成功,感谢任何帮助。
谢谢你。