1

我有如下给出的 HTML:

<root>
 <Customer cid= "C1" name="Janine" city="Issaquah">
  <input name="Client.ClaimsAdjudicationPendReason" />
  <a onclick="javascript:pendReasonLookup('MFM_Pend Reason', 'PendReason','txtClaimsAdjudicationPendReason','','')>
            <img title="Lookup" class="imgSearchIcon" alt="Lookup" src="/F005web/images/search.gif"/>


<input name="Client.ClaimsAdjudication" />
    <a onclick="javascript:pendReasonLookup('MFM_Pend Reason', 'PendReason','txtClaimsAdjudication','','')>
            <img title="Lookup" class="imgSearchIcon" alt="Lookup" src="/F005web/images/search.gif"/>

  </Customer>  
</root>

使用下面的 xpath,我可以选择“输入”节点,其中

name="Client.ClaimsAdjudicationPendReason"

xpath:=//input[@name='Client.ClaimsAdjudicationPendReason']

但我需要选择img节点(就在a标签下方)

name="Client.ClaimsAdjudicationPendReason"
4

1 回答 1

0

原始 html 缺少一些位,请参阅我上面的评论。因此,假设这是预期的:

<root>
    <Customer cid="C1" name="Janine" city="Issaquah">
        <input name="Client.ClaimsAdjudicationPendReason" />
        <a onclick="javascript:pendReasonLookup('MFM_Pend Reason', 'PendReason','txtClaimsAdjudicationPendReason','','')" />
        <img title="Lookup" class="imgSearchIcon" alt="Lookup" src="/F005web/images/search.gif" />
        <input name="Client.ClaimsAdjudication" />
        <a onclick="javascript:pendReasonLookup('MFM_Pend Reason', 'PendReason','txtClaimsAdjudication','','')" />
        <img title="Lookup" class="imgSearchIcon" alt="Lookup" src="/F005web/images/search.gif" />
    </Customer>
</root>

下面的 xpath 将选择 “Client.ClaimsAdjudicationPendReason”之后的第一个img节点inputname

//input[@name="Client.ClaimsAdjudicationPendReason"]/following-sibling::img[1]
于 2013-03-28T14:44:47.277 回答