HI!

What's the recommended way to implement a toString() method for an xml node?

Currently, I do:
  StreamResult streamResult;
  Transformer transformer;
  String result;

  streamResult = new StreamResult(new StringWriter());
  transformer = TransformerFactory.newInstance().newTransformer();   
  transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-16");
  transformer.transform(new DOMSource(node), streamResult);
  result = streamResult.getWriter().toString();

I use UTF-16, because Java strings are unicode. 

But then I still have to delete the version and encoding information from the 
result string, because I don't need them for an xml string in memory.

Any other ideas?

Thanks!

Regards,
Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to