I'm sure it should be obvious, but I could find any references on my question. What underlying technology does Scala XML uses? Is it something DOM-like or SAX-like or StAX like? What performance penalties should I be aware of when processing large documents? Is StA开发者_开发技巧X still more efficient?
Thanks in advance.
Large documents (several hundred of MB) can be processed with scala.xml.pull.XMLEventReader
. See nightly scaladoc (assuming you'll be using 2.8). This is using a pull parser model like StAX.
In general compared to Java, Scala is doing its own thing when dealing with XML. The XML is immutable. Also you can use XML literals directly in your Scala code which tends to make the code more readable.
In response to the comment, XML.load
uses javax.xml.parsers.{ SAXParser, SAXParserFactory } as underlying technology. I also assume that the resulting xml is loaded in memory.
Scala does its own thing. Most of the XML models out there are mutable, and do not translate well to immutability (because they keep track of parent, mostly).
Here's a paper about it.
精彩评论