I have the following DOM
<row>
<link href="Büro.txt" target="_blank">
my link
</link>
</row>
When I serialize it to a file using the Java XmlSerializer it comes out like this:
<row>
<link href="B&#252;ro.txt" target="_blank">
my link
</link>
</row>
Is there any way to control the way XmlSerializer handles escaping in attributes? Should I be doing this differently any way?
Update
I should also say that I am using jre 1.6. I had been using jre 1.5 until recently and I am pretty sure that it was serialized 'correctly' (i.e. the '&' was not escaped)
Clarification
The DOM is created programmatically. Here is an example:
Document doc = createDocument();
Element root = doc.createElement("root");
doc.appendChild(root);
root.setAttribute("test1", "ê");
root.setAttribute("test2", "üöä");
root.appendChild(doc.createTextNode("ê"));
StringWriter sw = new StringWriter();
serializeDocument(doc, sw);
System.out.println(sw.toString());
My solution
I didn't really want to do this because it involved a fair amount of code change and testing but I decided to move the attribute data into a CDATA element. Problem solved avoided.