檢查多個條件我想以檢索的行/場,其ID = 2和pAddress =印度如何在XPath
<?xml version="1.0"?>
<mysqldump >
<database name="MyDb">
<table name="DescriptionTable">
<row>
<field name="id">1</field>
<field name="pName">XYZ</field>
<field name="pAddress">INDIA</field>
<field name="pMobile">1234567897</field>
</row>
<row>
<field name="id">2</field>
<field name="pName">PQR</field>
<field name="pAddress">UK</field>
<field name="pMobile">755377</field>
</row>
<row>
<field name="id">3</field>
<field name="pName">ABC</field>
<field name="pAddress">USA</field>
<field name="pMobile">67856697</field>
</row>
</table>
</database>
</mysqldump>
String expression="/mysqldump/database[@name='MyDb']/table[@name='DescriptionTable']/row/field[@name='id' and ./text()]";
編輯的PName
:
我想得到PNAME whoese ID爲2和pAddress =印度
String expression="/mysqldump/database[@name='MyDb']/table[@name='DescriptionTable']/row/field[@name='id' and .='2']and[@name='pAddress' and .='INDIA']/../field[@name='pName']/text()";