我有以下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,我可以选择'input'节点
name="Client.ClaimsAdjudicationPendReason"
xpath:=//input[@name='Client.ClaimsAdjudicationPendReason']
但我需要选择img
节点(位于a
标签下方)
name="Client.ClaimsAdjudicationPendReason"
答案 0 :(得分: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将在img
input
之后选择第一个name
节点“Client.ClaimsAdjudicationPendReason”
//input[@name="Client.ClaimsAdjudicationPendReason"]/following-sibling::img[1]