import org.apache.xerces.parsers.DOMParser; import org.xml.sax.InputSource; import org.w3c.dom.Document; import org.w3c.dom.Element; DOMParser parser = new DOMParser(); String xmlFilePath = "path/to/xml/file.xml"; InputSource inputSource = new InputSource(xmlFilePath); parser.parse(inputSource); Document document = parser.getDocument(); Element rootElement = document.getDocumentElement(); for (int i = 0; i < rootElement.getChildNodes().getLength(); i++) { Element childElement = (Element) rootElement.getChildNodes().item(i); // ... }


上一篇:
下一篇:
切换中文