I’m trying to parse a multi line XML attribute in Java using the classic DOM. The parsing is working just fine. However, it’s destroying the line breaks so, when I render my parsed string, line breaks get replaced by simple spaces.
<string key="help_text" value="This is a multi line long
text. This should be parsed
and rendered in multiple lines" />
To get the attribute I’m using:
attributes.getNamedItem("value").getTextContent()
If I just pass a manually typed string to the render method using “\n”, the text gets drawn as intended.
Any ideas?
I’ve used JDom for this on the past. It saves you a lot of trouble when decoding multilined attributes and really enhances XML parsing/writing on Java. JDom is also compatible with Android development and it’s really tiny (only one jar file).
https://github.com/hunterhacker/jdom