我的 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");
}
感谢您的所有帮助
问候