我有以下 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"
);
关于Java xml 解析。通过一个函数调用深入浏览 xml 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32336931/