all groups > vj# > july 2007 >
You're in the

vj#

group:

J# XML output to screen


J# XML output to screen dcrackel
7/30/2007 2:40:35 PM
vj#: Greetings.

I'm having some trouble with what seems to be a simple issue.

I would like to write to a XML document to the System.out however, my
attempts are thwarted.


String exampleNamespaceURI = "http://example.com/2006/ns1";
XmlDocument xmlDocument = new XmlDocument();
XmlElement root = xmlDocument.CreateElement("", "root",
exampleNamespaceURI);
XmlElement test = xmlDocument.CreateElement("", "test",
exampleNamespaceURI);

test.AppendChild(xmlDocument.CreateTextNode("test text"));
root.AppendChild(test);
xmlDocument.AppendChild(root);
xmlDocument.Save("test.xml");

Rather than saving it to a file, I would like to write it to the
screen.

How could I that?


System.out.println("test:" + xmlDocument.toString()); = no good

Trying to use a Stream only yields can't initaite an absract class.

Thank you for the help
AddThis Social Bookmark Button