Whether working with DOM or SAX, the answer is the same: just put the
characters you want into a Text node's string value, as it would appear if
you had obtained the DOM by parsing a document. It's the serializer's
responsibility to render that appropriately when you output XML.
If you want a line break, XML's representation of line break is the newline
character (ASCII/Unicode 10). The serializer may convert that to CRLF if
that's the appropriate representation of line break on your system. (Note
that XML parsers must convert CRLF, CR, or LF to newline.)
If you really want a carriage return character, use it (ASCII/Unicode 13).
The serializer will recognize that the only way you can have this character
in XML content is if it was escaped, and will render it appropriately.
______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk