Akinatorus
Akinatorus

Reputation: 21

JDOM : XMLOutputter line breaks in attribute replaced by 


I have an XML document with an element that looks something like this:

<element attribute="this
has
line
breaks"/>

When I'm parsing it, this is outputted as:

<element attribute="this&#xA;has&#xA;line&#xA;breaks"/>

It's because, JDOM normalizes all the attribute values at its way, when it's not in an attribute (not in quotes), the value is well outputted. So I would like to know if it's possible to get back the same xml with its line breaks.

Thank you and I hope you understood my english :3

Upvotes: 1

Views: 673

Answers (1)

Akinatorus
Akinatorus

Reputation: 21

I resolved my problem this way, if it can help

XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat().setExpandEmptyElements(true)) {
                    @Override
                    public String escapeAttributeEntities(String str) {
                        str = str.replaceAll("\"", "&quot;");
                        return str;
                    }
};

Upvotes: 1

Related Questions