Xerces setTextContent method strips new lines / ca

2019-09-03 03:55发布

I'm using Xerces (Java) to generate XML documents. I have a large block of text (including carriage returns and new lines) that I would like to replicate exactly in my XML document as the text content of an element. For example:

<element>This is some text
here is some more
that's all folks</element>

However, whenever I try use:

element.setTextContent(myBlockOfText)

All the new lines are replaced with single space characters.

How can I keep the new lines within this block of text using Xerces? (Tried CDATA, but it's really only for quoting XML (left angle brackets etc) within XML itself).

1条回答
戒情不戒烟
2楼-- · 2019-09-03 04:26
登录 后发表回答