问题
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?
回答1:
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]);
}
回答2:
The solution was to use 

instead of \n
来源:https://stackoverflow.com/questions/3401111/preserve-newlines-when-parsing-xml