Hi folks,
This has probably been asked before, but I can't seem to access the
archives of the mail list, and I can't find a reference in any of the FAQs
Anyway, my question is this:
I have a method which is being called with a DOM Document, and I need to
serialize this DOM as XML and send the XML over an RMI connection to a remote
server. However from time to time, the remote server is generating a parse
error for certain input.
I am using an XMLSerializer (with an OutputFormat) to serialize the DOM to a
String (using a StringWriter), and then sending that string out to the remote
server
I suspect that occasionally the DOM I am getting contains characters such as �
and � within the text nodes, and that the XMLSerializer is writing those
characters to the String without escaping the characters to their entity
"strings".
I am using xerces2.2, with the following code:
DOMSource incomingDOM = (DOMSource) sources[0];
Document incomingDoc = incomingDOM.getNode().getOwnerDocument();
Element incomingElement = (Element) incomingDOM.getNode();
String incomingNamespace = incomingElement.getNamespaceURI();
OutputFormat format = new OutputFormat(incomingDoc); //Serialize
DOM
format.setOmitXMLDeclaration(true);
StringWriter incomingXML = new StringWriter(); //Writer will be a String
XMLSerializer serial = new XMLSerializer(incomingXML, format);
try {
serial.serialize(incomingElement);
} catch(Exception e) {
System.out.println("Serialization exception");
e.printStackTrace();
}
Any pointers would be appreciated....
Pete
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]