I'm using the SAX xml parser to parse some xml data which contains newlines. When using Attributes#getValue, the newline data is lost. How can keep the newlines?
Asked
Active
Viewed 1,590 times
3
-
Typical, after spending ages searching, I find the answer after posting this question. Solution was to use instead of \n – Al. Aug 03 '10 at 22:17
-
Can you describe a bit more? I am stucked and cant find much help. Thanks – kolslorr Apr 10 '11 at 06:03
-
Replace instances of \n with when exporting to xml. – Al. May 28 '11 at 22:07
-
Replace inside public void characters(char[] ch, int start, int length) ?? but char[] is already tempered after newLine , can you please elaborate your words ??? – Shailendra Singh Rajawat Jun 01 '11 at 09:32
-
You should post it as an answer and accept your own solution. That way people won't think this question still needs answering. – dcow May 20 '12 at 08:11
2 Answers
0
you can use this code when getting the String to parse:
public void characters(char ch[], int start, int length) {
for(int i=start; i<length; i++)
if(!Character.isISOControl(ch[i]))
content.append(ch[i]);
}

ghost rider3
- 448
- 1
- 5
- 17
-2
The solution was to use 

instead of \n

Al.
- 2,285
- 2
- 22
- 30
-
Please mention how you solved it in this answer, where it belongs :) – Jacob Ras Aug 23 '11 at 13:13