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

6.6 Accessing the Address

When you run the sample main, complexContent_main, the output shows a zip code and a complete XML document. This document is created by unmarshaling the input file complexContent.xml, changing a piece of data, and then marshaling the result to the output.

The beginning of the sample application is just like the previous examples:

Next the sample application manipulates the billTo element, which as we know can be either a USAddress or a UKAddress. In the code below, the retrieval of the billTo address returns an rwsf::XmlBindingHandle, but we do not know its actual type. To find out, we call getTypeId() on the billTo object, which returns the value of the xsi:type attribute of the billTo element in the instance document. Based on this value, we can determine the actual type of billTo and produce the output appropriately.

//1

Returns a rwsf::XmlBindingHandle which contains an Address, but whether a USAddress or a UKAddress is unknown.

//2

Uses getTypeId() method to determine the actual type and creates appropriate output based on the result.

Next the example code changes the shipTo address to be the same as the billTo address, and writes out the modified document.

//1

Sets the shipTo address to be the same as the billTo address.

//2

Instantiates a writer and sets it to preserve whitespace.

//3

Calls the marshal() method that marshals the data to a supplied writer.

//4

Writes out the XML document.



Previous fileTop of DocumentContentsIndex pageNext 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.
Contact Rogue Wave about documentation or support issues.