[英]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.