xpath从更深的节点搜索获取父节点的属性值

时间:2017-09-28 00:34:51

标签: xml xpath

我需要一个正则表达式,它会给我"资源"来自父节点的属性值,其中" Name" node =" BES支持"

<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
<ExternalSite Resource="https://server.domain.com:52311/api/site/external/BES%20Support">
<Name>BES Support</Name>
<GatherURL>http://sync.bigfix.com/cgi-bin/bfgather/bessupport</GatherURL>
</ExternalSite>
<CustomSite Resource="https://server.domain.com:52311/api/site/custom/DSE_Relays">
<Name>DSE_Relays</Name>
<GatherURL>http://server.domain.com:52311/cgi-bin/bfgather.exe/CustomSite_DSE_Relays</GatherURL>
</CustomSite>
<OperatorSite Resource="https://server.domain.com:52311/api/site/operator/idhere">
<Name>idhere</Name>
<GatherURL>http://server.domain.com:52311/cgi-bin/bfgather.exe/actionsite</GatherURL>
</OperatorSite>
</BESAPI>

1 个答案:

答案 0 :(得分:0)

//name[text()="BES Support"]/parent::*/@resource