2

I am trying to write an XML file using XMLStreamWriter. The problem is that I have an attribute value with "\r\n".

Since I am using an XML writer, I was expecting the writer to escape "\n" to 
 and "\r" to 
, but that does not happen. That causes the resulting file to have the attribute value splitted in multiple lines, and my application (based on EMF) ignores the new lines.

What I would like to do is to write the attribute's value with 
 and 
. How can I do that?

kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • Have you tried any methods of escaping the characters before you write to the file? – Anil Jan 07 '15 at 18:57
  • I tried to replace "\n" with " " and "\r" with " ". In this case, XMLStreamWriter will replace the "&" by "&". Therefore, the file will end up with "
" instead of "\n". The problem is, i gess, that both "\n" and " " represent the same byte (10) and what I need is XMLStreamWriter to write that byte as " " instead of "\n". – João Sequeira Jan 08 '15 at 09:04

0 Answers0