VTD-XML doesn't return the right value, how can I modiy the query to get the right result?

隐身守侯 提交于 2019-12-08 09:14:15

问题


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();

But when I try to query :

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

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?

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


回答1:


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.



来源:https://stackoverflow.com/questions/56815624/vtd-xml-doesnt-return-the-right-value-how-can-i-modiy-the-query-to-get-the-rig

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!