0
我有一個xml字符串,我想只比較選定的節點值,並在結果上聲明我的測試用例。 例如:我在XML字符串如何僅匹配xml的選定節點值?
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:requestTransferResponse xmlns:ns2="http://external.interfaces.my.company.com/">
<return>
<ersReference>2017051017472278401000061</ersReference>
<resultCode>0</resultCode>
<resultDescription>SUCCESS</resultDescription>
<receivedAmount>
<currency>BSD</currency>
<value>5500.00</value>
</receivedAmount>
<receiverPrincipal>
<principalId>
<id>SUBDIST1-1</id>
<type>RESELLERID</type>
</principalId>
<principalName>Sub Distributor 1</principalName>
<accounts>
<account>
<accountSpecifier>
<accountId>SUBDIST1-1</accountId>
<accountTypeId>RESELLER</accountTypeId>
</accountSpecifier>
<balance>
<currency>BSD</currency>
<value>985500.00</value>
</balance>
<creditLimit>
<currency>BSD</currency>
<value>0.00000</value>
</creditLimit>
</account>
</accounts>
<status>Active</status>
<msisdn>12420101000</msisdn>
</receiverPrincipal>
<requestedTransferAmount>
<currency>BSD</currency>
<value>5500</value>
</requestedTransferAmount>
<senderPrincipal>
<principalId>
<id>DIST1</id>
<type>RESELLERID</type>
</principalId>
<principalName>Distributor 1</principalName>
<accounts>
<account>
<accountSpecifier>
<accountId>DIST1</accountId>
<accountTypeId>RESELLER</accountTypeId>
</accountSpecifier>
<balance>
<currency>BSD</currency>
<value>1994429.24</value>
</balance>
<creditLimit>
<currency>BSD</currency>
<value>0.00000</value>
</creditLimit>
</account>
</accounts>
<status>Active</status>
<msisdn>12420100000</msisdn>
</senderPrincipal>
</return>
</ns2:requestTransferResponse>
</soap:Body>
</soap:Envelope>
下現在我想驗證其的XPath
1. //receiverPrincipal//balance//value i.e 985500.00
2. //senderPrincipal//balance//value i.e. 1994429.24
不需要其餘節點以下節點的值。所以我搜索了互聯網並找到了XmlUnit庫。任何人都可以提供一個關於如何使用它來驗證xpath節點值的提示嗎?