Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
HydraExpress XML Binding Development Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

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:

//1Constructs data, an empty instance of class targetType.
//2Loops until the reader is positioned just before an element with a name matching target.
//3Advances the reader over the next node in the document.
//4Populates 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 DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved. All Rights Reserved. Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. HydraExpress is a trademark of Rogue Wave Software, Inc. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.