我有这个xml,我也不知道如何获得名字给孩子的名字。
<return_message>
<status>True</status>
<return_value>
<folder_tree_node>
<folder>
<name>CR1</name>
<path>Root\Test Sets\WBTS SW CI\CR1</path>
</folder>
<folder_tree_node>
<folder>
<name>FB14.07</name>
<path>Root\Test Sets\WBTS SW CI\CR1\FB14.07</path>
</folder>
<folder_tree_node>
<folder>
<name>CW27_1</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1</path>
</folder>
<folder_tree_node>
<folder>
<name>Antenna Line Mng</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\ Line Mng</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>BTS start up & Rec</name>Antenna
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\BTS start up & Rec</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>CC & SM</name>
<path>Root\Test Sets\WBTS SW CI\CR1\FB14.07\CW27_1\CC
& SM</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>Frequency Variants</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\Frequency Variants</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>NetAct Interoperability</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\NetAct Interoperability</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>Pre-Stability</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\Pre-Stability</path>
</folder>
</folder_tree_node>w
<folder_tree_node>
<folder>
<name>RAB</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\RAB</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>Test & Measurements</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\Test & Measurements</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>Tracebility</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\Tracebility</path>
</folder>
</folder_tree_node>
<folder_tree_node>
<folder>
<name>Transmission</name>
<path>Root\Test Sets\WBTS SW
CI\CR1\FB14.07\CW27_1\Transmission</path>
</folder>
</folder_tree_node>
</folder_tree_node>
我想获取给定节点的子节点的所有名称。 I.E给出CW27_1,xpath将返回ff。天线线路Mng,BTS启动,CC&amp;放大器我应该做什么xpath?
答案 0 :(得分:1)
试
//folder_tree_node/folder/name[.='CW27_1']/../../folder_tree_node/descendant::name
它将获得以下内容:
<name>Antenna Line Mng</name>
<name>BTS start up & Rec</name>
<name>CC & SM</name>
<name>Frequency Variants</name>
<name>NetAct Interoperability</name>
<name>Pre-Stability</name>
<name>RAB</name>
<name>Test & Measurements</name>
<name>Tracebility</name>
<name>Transmission</name>