xml XPath count() 函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10176657/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 13:26:51  来源:igfitidea点击:

XPath count() function

xmlxpath

提问by emen

Suppose I have an XML tree as below:

假设我有一个 XML 树,如下所示:

proceedings
   -name
   -contents
      -article
         -author
         -title
         -pages

How can I identify any title that has only one author? And the number of articles that have more than three author using xpath?

如何识别只有一个作者的任何标题?使用 xpath 的作者超过三个的文章数量?

回答by Francis Avila

Title with one author:

一位作者的标题:

/proceedings/contents/article[count(author)=1]/title

Number of articles with more than three authors:

三名以上作者的文章数:

count(/proceedings/contents/article[count(author)>3])