Well, although this method works, it's non-standard. Explicitly using Xalan&Xerces' abilities is not considered as "standard".
The correct standard way of outputting a DOM document into a string is using JAXP's transformation API: Document myDoc; // Populate the document // Now output it as a string. StringWriter sw = new StringWriter(); (javax.xml.transform.dom.)DOMSource src = new DOMSource(myDoc); (javax.xml.transform.stream.)StreamResult result = new StreamResult(sw); (javax.xml.transform.)Transformer t = TransformerFactory.newInstance().newTransformer(); t.transform(src,result); // Now, sw.toString() will give you the string representation of the DOM document. ----- Original Message ----- From: "Voytenko, Dimitry" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, November 30, 2001 9:56 PM Subject: RE: XML output of DOM > Hi Tobias, > > You may try org.apache.xml.serialize.XMLSerializer class or if you use > Xalan: org.apache.xalan.serialize.SerializerToXML. You may find a lot of > utilities for serializing XML browsing these packages. > > Thanks, > Dmitry > > -----Original Message----- > From: Tobias McNulty [mailto:[EMAIL PROTECTED] > Sent: Friday, November 30, 2001 11:50 > To: [EMAIL PROTECTED] > Subject: XML output of DOM > > > What is the standard method of taking a DOM Document and outputting > it as XML (into a String)? > > Thanks, > -- > Tobias McNulty > Data Description, Inc. > 840 Hanshaw Road, Suite 9 > Ithaca, NY 14850 > Phone: (607) 257-1000 > E-mail: [EMAIL PROTECTED] > Web: www.datadesk.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
