stax

When should I choose SAX over StAX?

爱⌒轻易说出口 提交于 2019-11-26 18:47:53
问题 Streaming xml-parsers like SAX and StAX are faster and more memory efficient than parsers building a tree-structure like DOM-parsers. SAX is a push parser, meaning that it's an instance of the observer pattern (also called listener pattern). SAX was there first, but then came StAX - a pull parser, meaning that it basically works like an iterator. You can find reasons why to prefer StAX over SAX everywhere, but it usually boils down to: "it's easier to use". In the Java tutorial on JAXP StAX

Using StAX to create index for XML for quick access

夙愿已清 提交于 2019-11-26 14:25:41
问题 Is there a way to use StAX and JAX-B to create an index and then get quick access to an XML file? I have a large XML file and I need to find information in it. This is used in a desktop application and so it should work on systems with few RAM. So my idea is this: Create an index and then quickly access data from the large file. I can't just split the file because it's an official federal database that I want to use unaltered. Using a XMLStreamReader I can quickly find some element and then

What are the differences between DOM, SAX and StAX XML parsers? [closed]

大兔子大兔子 提交于 2019-11-26 11:28:21
问题 I\'m developing a RSS feed aggregator with Apache Tomcat. I was wondering which parser to use in order to read RSS feeds. Should I use DOM, SAX or StAX? I know that there are libraries specific to read RSS feeds with java but since this is a university project I am not supposed to use those. Thank you. 回答1: It mostly depends on your needs. Each has it's own features. DOM - pull the whole thing into memory and walk around inside it. Good for comparatively small chunks of XML that you want to

StAX XML formatting in Java

孤街醉人 提交于 2019-11-26 09:49:05
问题 Is it possible using StAX (specifically woodstox) to format the output xml with newlines and tabs, i.e. in the form: <element1> <element2> someData </element2> </element1> instead of: <element1><element2>someData</element2></element1> If this is not possible in woodstox, is there any other lightweight libs that can do this? 回答1: Via the JDK: transformer.setOutputProperty(OutputKeys.INDENT, "yes"); . 回答2: There is com.sun.xml.txw2.output.IndentingXMLStreamWriter XMLOutputFactory xmlof =

Is there a Java XML API that can parse a document without resolving character entities?

和自甴很熟 提交于 2019-11-26 07:49:01
问题 I have program that needs to parse XML that contains character entities. The program itself doesn\'t need to have them resolved, and the list of them is large and will change, so I want to avoid explicit support for these entities if I can. Here\'s a simple example: <?xml version=\"1.0\" encoding=\"UTF-8\"?> <xml>Hello there &something;</xml> Is there a Java XML API that can parse a document successfully without resolving (non-standard) character entities? Ideally it would translate them into

“Content is not allowed in prolog” when parsing perfectly valid XML on GAE

半腔热情 提交于 2019-11-26 07:35:28
问题 I\'ve been beating my head against this absolutely infuriating bug for the last 48 hours, so I thought I\'d finally throw in the towel and try asking here before I throw my laptop out the window. I\'m trying to parse the response XML from a call I made to AWS SimpleDB. The response is coming back on the wire just fine; for example, it may look like: <?xml version=\"1.0\" encoding=\"utf-8\"?> <ListDomainsResponse xmlns=\"http://sdb.amazonaws.com/doc/2009-04-15/\"> <ListDomainsResult>