Reputation: 1899
I want to create an xml file which have '&' in one of its text node. like
<url>www.sample.com/where/values?firstvalue=1&secondvalue=2</url>
Now what I am getting is
<url>www.sample.com/where/values?firstvalue=1&secondvalue=2</url>
Could you please let me know how can I achieve that. I am attaching the url value to dom using contenturl.appendChild(doc.createTextNode(model.getDocURL()));
and I am parsing using following method
DOMSource source = new DOMSource(doc);
transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(source, result);
Upvotes: 0
Views: 4050
Reputation: 64
Have you tried escaping the ampersand character as "...firstvalue=1\
secondvalue=2..." ?
Upvotes: -1
Reputation: 747
I agree with Rubens Farias that you probably want to leave it as &
which is a correctly escaped ampersand. However this question deals with unescaping html characters:
Convert HTML Character Back to Text Using Java Standard Library
Upvotes: 2