XMLWriter is designed for manual control of the XML creation process. You can generate tagged data using the startTag/endTag methods like so:
You can create multi-level XML like so:
Which wasn't the best way maybe, but it works.
For a simpler output, use printTag( tag, value ).
The printTag( vector, topic, tag ) was a convenience when I wanted to put out lists where each item was a tagged item under a topic.
You can also start a tag with attributes using startTag( tag, attributes ) where attributes is an array of objects in pairs like:
The EJBWizard is a GUI tool where you fill in data to define the Enterprise JavaBean you wish to construct and then do a File/Generate menu command to cause the prototype
EJB code and infrastructure (
JSP's,
Ant buildfile, etc. to be created. It's template driven to be easily extensible, but if what you're looking for is to output XML from an app you write, the XMLWriter class is the only one you need. The EJBWizard uses XMLWriter as a utility class to output a project (EJB definition) in XML format.
It's a good idea to escape your data when writing XML. In the example up top I used the print() method that XMLWriter inherits from printWriter, but there is also a printQuotedTag method as well as a static method that will take a
string and XML-escape it. Or you can manually generate CDATA blocks.