Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
HydraExpress XML Binding Development Guide

7.3 Working With Large Documents

If an XML document is so large that better performance could be provided by marshaling it in pieces, use class rwsf::XmlReader to read specific elements from the document. rwsf::XmlReader is an efficient pull-parser.

To unmarshal part of a document, use method isElementNext() and method readNextNode() to locate the element of interest. The code sample below iterates over the XML document until the reader is positioned at an element with the name targetType in the unnamed namespace. The sample then unmarshals this element into an instance of targetType, a class generated by HydraExpress:

//1

Constructs data, an empty instance of class TargetType.

//2

Loops until the reader is positioned just before an element with a name matching target.

//3

Advances the reader over the next node in the document.

//4

Populates data from reader.

A more general solution is to create a helper class to handle the iteration. The sample below shows a sample class template for reading specific elements from an XML reader. The interface is deliberately simple, and follows the interface of the Servlet class rwsf::Enumeration<T>:

To use the template, construct an instance of the XmlDocumentIterator specialized on the HydraExpress class to be read:



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo are registered trademarks of Rogue Wave Software, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.