e524. visiting all the nodes in a dom document.txt
来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 21 行
TXT
21 行
// Obtain an DOM document; this method is implemented in
// e510 The Quintessential Program to Create a DOM Document from an XML File
Document doc = parseXmlFile("infilename.xml", true);
visit(doc, 0);
// This method visits all the nodes in a DOM tree
public static void visit(Node node, int level) {
// Process node
// If there are any children, visit each one
NodeList list = node.getChildNodes();
for (int i=0; i<list.getLength(); i++) {
// Get child node
Node childNode = list.item(i);
// Visit child node
visit(childNode, level+1);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?