我有这个XML:
<incollection mdate="2017-05-16" key="reference/algo/NaFGP08"
publtype="encyclopedia entry">
<author>Joong Chae Na</author>
<author>Paolo Ferragina</author>
<author>Raffaele Giancarlo</author>
<author>Kunsoo Park</author>
<title>Two-Dimensional Pattern Indexing.</title>
<year>2008</year>
<booktitle>Encyclopedia of Algorithms</booktitle>
<ee>https://doi.org/10.1007/978-0-387-30162-4_442</ee>
<crossref>reference/algo/2008</crossref>
<url>db/reference/algo/algo2008.html#NaFGP08</url>
</incollection>
如何使用XPath选择Paolo Ferragina的所有共同作者?
答案 0 :(得分:0)
这个XPath,
/incollection[author = 'Paolo Ferragina']/author
将选择Paolo Ferragina的所有合着者,假设一个人可以成为自己的合着者。
没有这个假设,这个XPath
/incollection[author = 'Paolo Ferragina']/author[. != 'Paolo Ferragina']
将排除Paolo Ferragina。
或者,更真实地找到Paolo Ferragina的兄弟姐妹:
//author[preceding-sibling::author[. = 'Paolo Ferragina'] or
following-sibling::author[. = 'Paolo Ferragina']]