Input XML
<pageMeta>
<trail target="/">SAIR Home</trail>
<trail target="/handle/10862/1">SEAFDEC Aquaculture Department</trail>
<trail target="/handle/10862/46">SEAFDEC/AQD Publications</trail>
<trail target="/handle/10862/85">Institutional and Meeting Reports</trail>
<trail target="/handle/10862/699">Institutional Reports</trail>
<trail target="/handle/10862/527">Annual Reports</trail>
</pageMeta>
Using select="pageMeta/trail[@target][last()]
, I get the Annual Reports value. How can I get the value of the last @target
attribute which is /handle/10862/527
?
Thanks in advance.
您可以简单地将属性名称作为XPath表达式的最后一步来返回属性:
select="pageMeta/trail[@target][last()]/@target"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.