<bookstore>
<book category="COOKING">
<div lang="en">Everyday Italian</div>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price dollarValue="1.5">30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price dollarValue="1.5">29.99</price>
</book>
<book category="WEB">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price dollarValue="1.5">49.99</price>
</book>
<book category="WEB">
<p lang="en">Learning XML</p>
<author>Erik T. Ray</author>
<year>2003</year>
<price dollarValue="1.5">39.95</price>
</book>
</bookstore>
在上面的XML数据中
我想获得属性为lang="en"
所以这意味着匹配
<div lang="en">data</div>
<title lang="en">data</title>
<p lang="en">data</p>
节点不限于title,div,p
,可能还有更多节点。所以我不能单独查询这些
我该怎么做?
答案 0 :(得分:1)
您可以使用*
引用任何名称的元素节点,例如:
//*[@lang='en']/text()