我想用java解析XML。它将是 DOM 或 SAX。读一本书 JAXP 是不错的。当我用谷歌搜索时也发现了 XERCES/XALAN。常用哪种解析器?
在 SAX 解析器中,如果我注册单个元素事件,SAX 解析器会在遇到该元素后停止处理 XML 消息。阅读书籍 DOM 会读取整个 XML 并加载到内存中,即使我想知道单个元素值也是如此。
最佳答案
I want to parse XML in java. It will be DOM or SAX. Read in a book JAXP is good one. Also when i google out found XERCES/XALAN. Which parser is commonly used?
Xerces 是 DOM 和 SAX 的实现,并且内置于 JDK 中。请参阅javax.xml.parsers
。
In SAX Parser if i register for a single element event will the SAX parse stops processing the XML message after encountering the element.
没有。
Read in a book DOM reads the entire XML and loads into memory even if i want to know single element value.
是的。
关于java - 在 JAVA 中解析 XML 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9730701/