Adding Data to an XMLDocument Object

Figure 1. Adding to an XMLDocument
add(Object value);
addFromXML(String xmlFragment);

The add() method of the XMLDocument class can be used to produce XML data from an instance of a struct class.

For documents opened with the open() method, you may only issue a single call to add() before closing your document. For documents opened with openForList(), you may use several calls to add() but should ensure that you only add instances of the same struct class type.

addFromXML() is a convenience method allowing an XML fragment to be directly added to the document, rather than using the struct class. It is the responsibility of the caller to ensure this fragment respects the DTD.