private void traverse(Node node, int height) {
switch (node.getNodeType()) {
case Node.DOCUMENT_NODE:
...
break;
case Node.ELEMENT_NODE:
...
break;
case Node.TEXT_NODE:
...
break;
case Node.CDATA_SECTION_NODE:
...
break;
case Node.COMMENT_NODE:
...
break;
case Node.PROCESSING_INSTRUCTION_NODE:
...
break;
}
NodeList nodeList = node.getChildNodes();
Node child = node.getFirstChild();
while (child != null) {
traverse(child, height);
child = child.getNextSibling();
}
}
Thursday, January 6, 2011
Use DOM to traverse a XML tree - Java code
Labels:
XML
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment