繁体   English   中英

Xpath:如果存在子代,如何在xpath中选择父注释的值

[英]Xpath: How to select value of parent note in xpath if child exists

我尝试用xml之外的javascript构建html表

因此,如果存在例如// host的子代,那么我需要来自具有xpath的另一个祖先的父元素的值,该父元素名为“ name”

我只需要xpath中的频道名称:

"/serverConfiguration/channels/channel/name"

孩子在哪里

"/serverConfiguration/channels/channel/sourceConnector/properties/listenerConnectorProperties/host"

存在

就XPath而言,似乎您只需要谓词/serverConfiguration/channels/channel[.//host]/name/serverConfiguration/channels/channel[sourceConnector/properties/listenerConnectorProperties/host]/name

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM