[英]Xpath: How to select value of parent note in xpath if child exists
I try to build a html table with javascript out of a xml 我尝试用xml之外的javascript构建html表
Therefore I need the value of a parent element from a different ancestor called "name" with xpath, if a child with eg //host exists 因此,如果存在例如// host的子代,那么我需要来自具有xpath的另一个祖先的父元素的值,该父元素名为“ name”
I need only the channel name out of the xpath: 我只需要xpath中的频道名称:
"/serverConfiguration/channels/channel/name"
where the child 孩子在哪里
"/serverConfiguration/channels/channel/sourceConnector/properties/listenerConnectorProperties/host"
exists 存在
就XPath而言,似乎您只需要谓词/serverConfiguration/channels/channel[.//host]/name
或/serverConfiguration/channels/channel[sourceConnector/properties/listenerConnectorProperties/host]/name
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.