1

I want to write a simple message with a line break in the middle. I know that in Java you can do something like the following:

"Hey, this is a message" + \n + "...and this is the rest of it on a new line"

How can I do the same in XML? Can I use the \n escape character or do I use the html line break?

I would like to add a message to the following element in the ObjectValue attribute:

<EnterValue ScreenName="" ObjectName="EMAIL_MESSAGE" ObjectValue=""/>
neuquen
  • 3,991
  • 15
  • 58
  • 78
  • possible duplicate of [Line Break in XML?](http://stackoverflow.com/questions/2986297/line-break-in-xml) – Anirudh Ramanathan Aug 09 '13 at 16:15
  • @DarkCthulhu: not precisely a duplicate - the cited question aims at inserting content of xml elements into html, the latter requiring a markup representation of a newline. – collapsar Aug 09 '13 at 16:21

1 Answers1

2

use the numrical entity representation of xml: &#x<hex code of char>;, eg &#x0a;,&#x0d; for a LF, CR, respectively.

note that this method works without regard to the character set and/or encoding being used as the byte range 0x00 - 0x7f is shared by all encodings (roughly speaking at least. ebcdic will be different. but the dichotomy between unicode encodings vs. byte-oriented charsets will be covered).

collapsar
  • 17,010
  • 4
  • 35
  • 61