I tried to replace some special characters, like:
xmlData=xmlData.replaceAll(">",">"); xmlData=xmlData.replaceAll("&","&"); //but it doesn't work.
<category label='ARR Builders & Developers'>
Consider generating the XML using DOM methods. For example:
var c = document.createElement("category"); c.setAttribute("label", "ARR Builders & Developers"); var s = new XMLSerializer().serializeToString(c); s; // => "<category label=\"ARR Builder & Developers\"></category>"
This strategy should avoid the XML entity escaping problems you mention but might have some cross-browser issues.
xml = xml.replace(/</g, "<"); xml = xml.replace(/>/g, ">");
This uses regular expression literals to replace all less than and greater than symbols with their escaped equivalent.