Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml Xpath如何使用另一个元素文本值获取一个元素_Xml_Xpath - Fatal编程技术网

Xml Xpath如何使用另一个元素文本值获取一个元素

Xml Xpath如何使用另一个元素文本值获取一个元素,xml,xpath,Xml,Xpath,我正在尝试为我的自动测试创建xpath。我有以下代码: <span class="left-floated"> <input class="PfcExecutiveBrief" type="checkbox" value="PfcExecutiveBrief" name="DocumentTypeResearch"/> <label for="PfcExecutiveBrief">Executive Brief</label> &l

我正在尝试为我的自动测试创建xpath。我有以下代码:

<span class="left-floated">
   <input class="PfcExecutiveBrief" type="checkbox" value="PfcExecutiveBrief" name="DocumentTypeResearch"/>
   <label for="PfcExecutiveBrief">Executive Brief</label>
  <br/>
   <input class="Memo" type="checkbox" value="PfcMemo" name="DocumentTypeResearch"/>
   <label for="PfcMemo">Memo</label>
  <br/>
   <input class="PfcOtherResearchForNaturalGasOrOil" type="checkbox" checked="checked" value="PfcOtherResearchForNaturalGasOrOil" name="DocumentTypeResearch" disabled=""/>
   <label for="PfcOtherResearchForNaturalGasOrOil">Other Research</label>
  <br/>
   <input class="PfcProfile" type="checkbox" value="PfcProfile" name="DocumentTypeResearch"/>
   <input type="hidden" value="PfcOtherResearchForNaturalGasOrOil" name="DocumentTypeResearch"/>
   <label for="PfcProfile">Profile</label>
  <br/>
</span>

如何获取第二个输入等。

尽管此处误用了
@for
属性(),但您可以使用它解析为使用相同
@value
属性的匹配输入

//输入[@value=../label[text()='Memo']/@for]
如果标签可能在文档中的任何位置(而不是像您的示例中那样是同级标签),您还可以再次从根目录进行搜索:

//输入[@value=//标签[text()='Memo']/@for]
label[text()='Memo']