XML文件解析
代码:
InputStream inputStream = this.getClass().getResourceAsStream(xmlPath);
Document document = XmlUtil.readXML(inputStream);
Element element = document.getDocumentElement();
NodeList entityList = element.getElementsByTagName("item");
for (int i = 0; i < entityList.getLength(); i++) {
String content = entityList.item(i).getTextContent();
System.out.println(content);
}
xml文件案例:
评论区