VTD-XML没有返回正确的值,如何修改查询以获得正确的结果? [英] VTD-XML doesn't return the right value, how can I modiy the query to get the right result?

查看:90
本文介绍了VTD-XML没有返回正确的值,如何修改查询以获得正确的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下函数通过VTD-XML解析xml:

I'm using the following function to parse xml using VTD-XML:

final AutoPilot ap = new AutoPilot(vtdNav);
ap.selectXPath(path);
int i = -1;
/** evalXPath returns -1 if no new node is present */
while ((i =  ap.evalXPath()) != -1) {
     extractedValues.add(vtdNav.toString(i+1));
}
/** Reset the XPath */
ap.resetXPath();

但是当我尝试查询时:

<actualUnitCost>
  <chargeOrAllowance>CHARGE</chargeOrAllowance>
  <monetaryAmount currencyISOCode="USD">17.08</monetaryAmount>
</actualUnitCost>

使用路径: /actualUnitCost/monetaryAmount 它给我的值是currencyISOCode而不是17.08.如何修改查询以获得所需的结果?

using the path : /actualUnitCost/monetaryAmount it gives me the value as currencyISOCode instead of 17.08. How can I modify the query to get the desired result?

我已经尝试过/actualUnitCost/monetaryAmount/text(),但无法给出正确的答案.

I've tried /actualUnitCost/monetaryAmount/text() but it doesn't yield the right answer.

推荐答案

我认为这是正确的行为.如果您尝试/actualUnitCost/monetaryAmount/text(),它将为您提供文本节点.

I think that is the correct behavior. If you try /actualUnitCost/monetaryAmount/text(), it will give you the text node.

让我知道是否有任何问题.

Let me know if there is any question.

这篇关于VTD-XML没有返回正确的值,如何修改查询以获得正确的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆