我确实有一个示例XML
文件:-
<?xml version="1.0"?>
<bookstore>
<book>
<title>The Weather Pattern</title>
<author>Weather Man</author>
<price>100.00</price>
</book>
<book>
<title>Weaving Patterns</title>
<author>Weaver</author>
<price>150.00</price>
</book>
<book>
<title>Speech Pattern</title>
<author>Speaker</author>
<price>15.00</price>
</book>
<book>
<title>Writing Style</title>
<author>Writer</author>
<price>1500.00</price>
</book>
</bookstore>
我将XPATH表达式写为:
//author[starts-with(text(),'We')]/../*[local-name(.) = 'price' or local-name(.) = 'author']/text()
输出
Weather Man
100.00
Weaver
150.00
我正在寻找经过修改、简化的 xpath 表达式来获得相同的输出。也欢迎不同的想法。有帮助吗?