0

我的 XML

<catalog>
<item Id="1">
<book id="b1">
</book>
<cd id="c1">
</cd>
</item>

<item Id="11">
<book id="b11">
</book>
<cd id="c11">
</cd>
</item>
</catalog>

我有的 ..

ap.selectXPath("/catalog/item");
while ((result = ap.evalXPath()) != -1) {
if (vn.toElement(VTDNav.FIRST_CHILD, "item")) {
do {
//do something with the contnets in the item node 
} while (vn.toElement(VTDNav.NEXT_SIBLING, "book"));
}

// 移动到父节点遍历其余的项目 }

我想要的是到达“cd”节点。

在一些示例中,我看到了 VTDNav.NEXT_CHILD 但似乎不可用。谁能建议如何到达我需要的节点。现在我设法通过到达 FIRST_CHILD 然后移动到下一个兄弟姐妹来做到这一点

if (vn.toElement(VTDNav.FIRST_CHILD, "book")) {
                    // Move to the next sibling 
                    vn.toElement(VTDNav.NEXT_SIBLING, "cd");

                }

感谢您的所有帮助

问候

4

1 回答 1

0

你不应该有下一个孩子。在您致电 FIRST_CHILD 之后,您寻找的可能是 NEXT_SIBLING...

于 2016-01-30T08:55:38.820 回答