Saturday, 17 August 2013

Java - Handle indentation in "getTextContent()" of DOM parsed XML

Java - Handle indentation in "getTextContent()" of DOM parsed XML

I've written some java code that parses an XML using DOM for loading data
in a program of mine. Formatting the XML with Eclipse "format" function,
I've encountered a problem: the previous working getTextContent() from a
document element, now returns a string that contains the whitespaces (or
whatelse) added from Eclipse's formatting. I'm looking for a solution that
given:
<myElement> some text
of mine
</myElement>
when I code-select the element <myElement> from the document, I want the
getTextContent() to behave like:
myElement.getTextContent().equals("some text of mine");
while it actually fails.
If I'm being too non-specific, tell me, thanks.

No comments:

Post a Comment