Universal Messaging 10.3 | Developer Guide | Enterprise APIs | Enterprise Developer's Guide for Java | Publish / Subscribe Using Channels/Topics | Sending XML Dom Objects
 
Sending XML Dom Objects
Universal Messaging provides inbuilt support for XML based messaging.
XML can be published as either a String or a DOM Document object.
A summary of the code needed to publish and consume XML data is provided below. For more information please see the Universal Messaging publish XML and consume XML examples.
Publishing
The code to read an XML file and publish it as DOM Document is as follows:

//Create an input stream
InputStream is = new FileInputStream( aFile );

//Create a DOM Parser object
DOMParser p = new DOMParser();

//Parse from the input stream
p.parse( new InputSource( is ) );

//Get the XML Document
doc = p.getDocument();

//Publish the Dom Document
myChannel.publish( tag, doc )
Subscribing
The code to consume XML is as follows:

//The nConsumEventListener Callback
void go( nConsumeEvent evt ) {

//get the DOM Document from the Universal Messaging event
Document doc = evt.getDocument()>

//pass it to the Universal Messaging xmlHelper class
xmlHelper xh = new xmlHelper( doc );

//output the XML to standard out
xh.dumpDoc();
}