You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Frank Taffelt <fr...@interface-business.de> on 2000/11/03 14:01:33 UTC
newlines ind document
Hi,
i have problems to insert newlines into my document.
i tried this code:
Document doc= new DocumentImpl();
Element root = doc.createElement("person");
Element item = doc.createElement("name");
item.appendChild( doc.createTextNode("Jeff \r\n newLine") );
root.appendChild( item );
item = doc.createElement("age");
item.appendChild( doc.createTextNode("28" ) );
root.appendChild( item );
item = doc.createElement("height");
item.appendChild( doc.createTextNode("1.80" ) );
root.appendChild( item );
doc.appendChild( root );
OutputFormat format = new OutputFormat( doc );
XMLSerializer serial = new XMLSerializer( newFileWriter("dom1.xml"), format );
serial.asDOMSerializer();
serial.serialize( doc.getDocumentElement() );
the generated file contains no newlines, it seems that "\r\n" is replaced
by 0x20 0x20. How can i create TextNodes with newlines ?
Thanks,
Frank