This works correctly for me.
Post by Stevenson, Todd (GE Healthcare)import nu.xom.Document;
import nu.xom.Element;
import nu.xom.Serializer;
void createXML() throws IOException {
Element root = new Element("Root");
Element child = new Element("Child");
Post by Stevenson, Todd (GE Healthcare)child.appendChild("\n first line \n second line\n");
root.appendChild(child);
Document doc = new Document(root);
Serializer serializer = new Serializer(System.out, "ISO-8859-1");
serializer.setIndent(4);
serializer.setMaxLength(100);
serializer.write(doc);
}
<?xml version="1.0" encoding="ISO-8859-1"?>
<Root>
<Child> first line second line</Child>
</Root>
Note that it discards the extra white space and newline characters. I want to be able to preserve this whitespace to the output XML document.
Thanks
-----Original Message-----
From: xom-interest-bounces at lists.ibiblio.org [mailto:xom-interest-bounces at lists.ibiblio.org] On Behalf Of Elliotte Rusty Harold
Sent: Wednesday, January 18, 2012 1:57 PM
To: XOM API for Processing XML with Java
Subject: Re: [XOM-interest] Preserve white space in text nodes
Post by Stevenson, Todd (GE Healthcare)I can't figure out how to preserve whitespace in a text node.
I use the serializer to write my output and it strips the spaces and newline characters.
Is there a configuration option to make this work correctly?
Do you have code that demonstrates what's happening?
--
Elliotte Rusty Harold
elharo at ibiblio.org
_______________________________________________
XOM-interest mailing list
XOM-interest at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest
_______________________________________________
XOM-interest mailing list
XOM-interest at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest