/**
* Prints all node names, attributes to file
* @param node a node that need to be recursively access.
* @param bWriter file writer.
* @throws IOException if writing file failed.
*/
private void writeNodes(Node node, BufferedWriter bWriter) throws IOException {
String str = "Node: " + node.getNodeName();
bWriter.write( str, 0,str.length());
bWriter.newLine();
NamedNodeMap nnm = node.getAttributes();
if (nnm != null && nnm.getLength() > 0)
for (int i=0; i<nnm.getLength(); i++) {
str = "AttributeName:" + ((Attr) nnm.item(i)).getName() +
", AttributeValue:" +((Attr) nnm.item(i)).getValue();
bWriter.write( str, 0,str.length());
bWriter.newLine();
}
NodeList kids = node.getChildNodes();
if (kids != null)
for (int i=0; i<kids.getLength(); i++)
writeNodes(kids.item(i), bWriter);
}
DOMResultTest.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:openjdk-jdk10
作者:
评论列表
文章目录