xml

(解析器)DocumentBuilder.parse(File f)
将给定文件的内容解析为一个 XML 文档,并且返回一个新的 DOM Document 对象。

通过解析器 解析文档后得到的返回类型是Document接口类型的实现类

Document,Element是Node(节点)的子接口


DOMSource是个源
DOMSource(Node node)的构造方法中就可以把Document当参数传入

得到元素的值
String adress = ele2.getAttribute("adress"); //得到属性的值
String num=ele2.getTextContent(); //得到文本内容

原文地址:https://www.cnblogs.com/m97i/p/6915923.html