我想让作者处于第三的位置。我正在使用//作者[3]。这种方式有什么理由不起作用吗?当我输入//作者[1]时,我得到了整行。
<publications>
<publication>
<publication_name> Group agency: The possibility, design, and status of corporate agents </publication_name>
<authors> C List,P Pettit </authors>
<publisher> Oxford University Press </publisher>
<year> 2011 </year>
<citation> 598 </citation>
</publication>
<publication>
<publication_name> Aggregating sets of judgments: An impossibility result</publication_name>
<authors> C List, P Pettit </authors>
<publisher> Economics and Philosophy </publisher>
<volume> 18 </volume>
<number> 1 </number>
<pages> 89- 110 </pages>
<citation> 558 </citation>
<year> 2002 </year>e
</publication>
<publication>
<publication_name> Epistemic democracy: generalizing the Condorcet jury theorem</publication_name>
<authors> C List, RE Goodin </authors>
<publisher> Journal of Political Philosophy </publisher>
<volume> 9 </volume>
<number> 3 </number>
<pages> 277-306 </pages>
<citation> 409 </citation>
<year> 2001 </year>
</publication>
<publication>
<publication_name> Arrow’s theorem in judgment aggregation </publication_name>
<authors> F Dietrich, C List </authors>
<publisher> Social Choice and Welfare </publisher>
<volume> 29 </volume>
<number> 1 </number>
<pages> 19 - 33 </pages>
<citation> 220 </citation>
<year> 2007 </year>
</publication>
<publication>
<publication_name> Deliberation, single-peakedness, and the possibility of meaningful democracy: evidence from deliberative polls </publication_name>
<authors> C List, RC Luskin, JS Fishkin, I McLean </authors>
<publisher> Journal of Politics </publisher>
<volume> 75 </volume>
<number> 01 </number>
<pages> 80-95 </pages>
<citation> 143 </citation>
<year> 2013 </year>
</publication>
<publication>
<publication_name> Swarm intelligence: When uncertainty meets conflict </publication_name>
<authors> L Conradt, C List, TJ Roper </authors>
<publisher> The American Naturalist </publisher>
<volume> 182 </volume>
<number> 5 </number>
<pages> 592-610 </pages>
<citation> 10 </citation>
<year> 2013 </year>
</publication>
<publication>
<publication_name> Intradimensional Single-peakedness and the Multidimensional Arrow Problem </publication_name>
<authors> C List </authors>
<publisher> Theory and Decision </publisher>
<citation> 10 </citation>
<year> 2004 </year>
</publication>
<publication>
<publication_name> The methodology of political theory </publication_name>
<authors> C List, L Valentini </authors>
<publisher> The Oxford Handbook of Philosophical Methodology </publisher>
<citation> 8 </citation>
<year> 2016 </year>
</publication>
<publication>
<publication_name> Social choice theory and deliberative democracy: a response to Aldred </publication_name>
<authors> JS Dryzek, C List </authors>
<publisher> British Journal of Political Science </publisher>
<volume> 34 </volume>
<number> 4 </number>
<pages> 752-758 </pages>
<citation> 8 </citation>
<year> 2004 </year>
</publication>
<publication>
<publication_name> Episteme symposium on group agency: Replies to Gaus, Cariani, Sylvan, and Briggs </publication_name>
<authors> C List, P Pettit </authors>
<publisher> Episteme </publisher>
<volume> 9 </volume>
<number> 3 </number>
<pages> 293 </pages>
<citation> 5 </citation>
<year> 2012 </year>
</publication>
<publication>
<publication_name> Two intuitions about free will: Alternative possibilities and intentional endorsement </publication_name>
<authors> C List, W Rabinowicz </authors>
<publication> Philosophical Perspectives </publication>
<volume> 28 </volume>
<number> 1 </number>
<pages> 155-172 </pages>
<citation> 4 </citation>
<year> 2014 </year>
</publication>
<publication>
<publication_name> Reasons for (prior) belief in Bayesian epistemology </publication_name>
<authors> F Dietrich, C List </authors>
<publisher> Synthese </publisher>
<volume> 190 </volume>
<number> 5 </number>
<pages> 787-808 </pages>
<citation> 4 </citation>
<year> 2013 </year>
</publication>
<publication>
<publication_name> Freedom as independence </publication_name>
<authors> C List, L Valentini </authors>
<publisher> Ethics </publisher>
<volume> 126 </volume>
<number> 4 </number>
<pages> 1043-1074 </pages>
<citation> 3 </citation>
<year> 2016 </year>
</publication>
<publication>
<publication_name> Belief revision generalized: A joint characterization of Bayes' and Jeffrey's rules </publication_name>
<authors> F Dietrich, C List, R Bradley </authors>
<publisher> Journal of Economic Theory </publisher>
<volume> 162</volume>
<pages> 352–371 </pages>
<citation> 3 </citation>
<year> 2016 </year>
</publication>
<publication>
<publication_name>Which worlds are possible? A judgment aggregation problem</publication_name>
<authors>C List</authors>
<publisher>Journal of Philosophical Logic</publisher>
<volume>37</volume>
<number>1</number>
<pages>57-65</pages>
<citation>12</citation>
<year>2008</year>
</publication>
</publications>
我只想让作者处于第三位。
没有结果,我收到一条错误消息:XPath查询没有返回任何结果。 XPath范围:当前文件。
答案 0 :(得分:1)
对于Xpath 1.0,您可以使用下一个表达式
//authors[substring-after(substring-after( . ,',' ),',')]
/substring-before(concat(normalize-space(substring-after(substring-after(.,',' ),',')),","),",")
Xpath的第一部分选择authors
标记,其中不少于2个逗号。
如果你想让第三作者的名字不使用编程语言,第二部分就是这样做的。
我为了便于阅读而拆分了Xpath
答案 1 :(得分:0)
此 XPath 2.0 表达式
//authors[count(tokenize(.,',')) > 2]/tokenize(.,',')[3]
将选择为每个出版物列出的第三位作者
JS Fishkin
TJ Roper
R Bradley
对于那些有3个或更多作者的author
元素(通过逗号分隔确定)。
XPath 1.0解决方案留给读者练习。
答案 2 :(得分:0)
除了其他人所说的内容之外,请注意//authors[1]
选择每个authors
元素作为其父级的第一个authors
子元素,而(//authors)[1]
选择第一个authors
元素整个文档中的{1}}元素,我认为你想要的是什么。
(你谈到了获得“整行”。我不知道XML上下文中的“行”是什么。如果你想清楚地沟通,第一条规则是学习技术词汇......)< / p>
答案 3 :(得分:0)
您可以使用此xpath选择第三位作者
employee_list = Employee.objects.filter(company = auth_employee.employee.company.id).values("id", "username").order_by('id')