我有以下xml文件

<basicCallInformation>
   <chargeableSubscriber>
       <simChargeableSubscriber>
           <imsi>26 20 32 23 16 62 80 3F</imsi>
           <msisdn>49 16 32 70 04 00</msisdn>
       </simChargeableSubscriber>
   </chargeableSubscriber>
</basicCallInformation>


我想直接转到节点“ imsi”和“ msisdn”,以便在可能的情况下通过一个函数调用获取它们的值。像这样

basicCallInformationNode.getNode('chargeableSubscriber/simChargeableSubscriber/imsi'); //something like this can be done in PLSQL


有没有办法用Java做到这一点?任何解决方法?

附言我正在使用DOM解析器

最佳答案

当然,

        XPath.evaluate(
    "/basicCallInformation/chargeableSubscriber/simChargeableSubscriber/imsi |
     /basicCallInformation/chargeableSubscriber/simChargeableSubscriber/msisdn"
        );

09-27 12:38