鉴于此XML:
<?xml version="1.0" encoding="UTF-8"?>
<r>
<Rk>
<Req>111</Req>
<RkNumber>123456</RkNumber>
<RkName>John</RkName>
</Rk>
<Rk>
<Req>111</Req>
<RkNumber>9876</RkNumber>
<RkName>Joe</RkName>
</Rk>
<Covg>
<Req>111</Req>
<RkNumber>123456</RkNumber>
<CvgNumber>123</CvgNumber>
</Covg>
<Covg>
<Req>111</Req>
<RkNumber>9876</RkNumber>
<CvgNumber>321</CvgNumber>
</Covg>
<Comp>
<Req>111</Req>
<CvgNumber>123</CvgNumber>
<CompTyp>ABC</CompTyp>
</Comp>
<Comp>
<Req>111</Req>
<CvgNumber>321</CvgNumber>
<CompTyp>DEF</CompTyp>
</Comp>
</r>
我想选择RkName
=&#39; ABC&#39;的CompTyp
。
我试过这个XPath,
//Rk[RkNumber = //Covg/RkNumber and //Covg/CvgNumber = //Comp/CvgNumber and //Comp[CompTyp = 'ABC']]/RkName
但它返回&#34; John&#34;和&#34;乔&#34;。我只希望有&#34; John&#34;返回。
答案 0 :(得分:1)
使用此XPath,
//Rk[RkNumber=//Covg[CvgNumber=//Comp[CompTyp='ABC']/CvgNumber]/RkNumber]/RkName
通过RkName
选择与Covg
相关联的RkNumber
,Comp
通过CvgNumber
通过Comp
与CompTyp
相关联使用ABC
<RkName>John</RkName>
,
@Override
public boolean onLongClick(View view) {
if (!mMultiSelector.isSelectable()) {
((AppCompatActivity) getActivity()).startSupportActionMode(mActionModeCallback); // (2)
mMultiSelector.setSelectable(true);
mMultiSelector.setSelected(MyViewHolder.this, true);
return true;
}
return false;
}
按要求。