Dustin E. Dustin E. - 1 year ago 96
Java Question

Stream content of an XML node using Axiom

I have an

that contains XML, that contains content that is escaped XML. The Escaped XML can be hundreds of Megabytes in size so it must be processed as its own XML document to prevent Apache Axiom's OMElement from loading the whole content into memory.

Is it possible, using Axiom, to stream the content of the node and parse it as a separate document?

Answer Source

The correct way to do this in Axiom is to call getTextAsStream (with cache set to false) on the OMElement that wraps the escaped XML, then parse the returned Reader as XML. Note that this only works if you tell Axiom to disable coalescing in the underlying XML parser, as described here; if you don't do this, then the entire content would still be loaded into memory.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download