1
解析
我已經被解析具有以下簡單的XML結構:問題在XML通過Java
<Nodes> <Node id="1"> <att1> <att2> ... </Node> <Node id="2"> ... </Nodes>
現在的問題很簡單,雖然通過Java代碼解析這個文件我收到「換行符」作爲單獨的節點,其在處理導致了這個複雜......我甚至使用DOMParsers正規化方法,但它似乎並沒有工作..下面 是解析器代碼:
public LogParser(File XMLFile) throws ParserConfigurationException,
SAXException, IOException {
//Logger.printInfoMessage("XML file to be parsed is "+XMLFile.toString());
DocumentBuilder documentBuilder = getDocumentBuilder();
doc = documentBuilder.parse(XMLFile);
doc.normalizeDocument();
}
試試這個鏈接http://www.java-samples.com/showtutorial.php?tutorialid=152 – Ajay 2012-02-24 06:43:15
我更喜歡STaX解析。 – brettw 2012-02-24 07:19:12
@brettw - 您的偏好已被記錄。 – 2012-02-24 07:44:03