I'm using VTD to parse and split very large XML files and require the actual XPath of the current element pointed to by the cursor after a call to AutoPilot.evalXPath()
.
我正在使用VTD来解析和分割非常大的XML文件,并且在调用AutoPilot.evalXPath()之后需要游标指向的当前元素的实际XPath。
Consider the following XML:
请考虑以下XML:
<atlas>
<continents>
<continent>
<name>North America</name>
<countries>
<country>
<name>Canada</name>
</country>
<country>
<name>US</name>
</country>
</countries>
</continent>
<continent>
<name>South America</name>
<countries>
<country>
<name>Chile</name>
</country>
<country>
<name>Brazil</name>
</country>
</countries>
</continent>
</continents>
</atlas>
I am initializing AutoPilot
with autopilot.selectXPath("/atlas/continents/continent/countries/country");
我正在使用autopilot.selectXPath(“/ atlas / continents / continent / countries / country”)初始化AutoPilot;
As I iterate through the matches using autopilot.evalXPath()
, I need the absolute XPath of each element, for example like /atlast/continents/continent[1]/countries/country[2]
.
当我使用autopilot.evalXPath()迭代匹配时,我需要每个元素的绝对XPath,例如像/ atlast / continents / continent [1] / countries / country [2]。
I tried almost all methods in VTDNav
and AutoPilot
-
我尝试了VTDNav和AutoPilot中的几乎所有方法 -
VTDNav.getXPathStringVal() / VTDNav.getXPathStringVal(short mode)
VTDNav.toNormalizedXPathString(int j)
AutoPilot.getExprString()
VTDNav.getXPathStringVal()/ VTDNav.getXPathStringVal(短模式)
Any ideas?
1 个解决方案
#1
0
I don't think vtd offers a function in the current release, in fact I am not aware of any api that offers this. I think the reason is that there are many different possible XPaths for any current element node... what do you think?
我不认为vtd在当前版本中提供了一个功能,事实上我并不知道任何提供此功能的api。我认为原因是任何当前元素节点都有许多不同的XPath ......你怎么看?
#1
0
I don't think vtd offers a function in the current release, in fact I am not aware of any api that offers this. I think the reason is that there are many different possible XPaths for any current element node... what do you think?
我不认为vtd在当前版本中提供了一个功能,事实上我并不知道任何提供此功能的api。我认为原因是任何当前元素节点都有许多不同的XPath ......你怎么看?