JavaScript comes with a powerful replace() method for string objects.
In general - and basic - terms, it works as follows:
var myString = yourString.replace([regular expression or simple string], [replacement string]);
The first argument to the .replace() method is the part of the original string that you want to replace. It can be represented either by a simple string object (even a literal), or by a regular expression.
Regular expression is obviously the most powerful way to select a substring.
The second argument is a string object (even a literal) that you want to provide as a replacement.
In your case, the replacement operation should look like this:
xmlData=xmlData.replace(/&/g,"&"); xmlData=xmlData.replace(/>/g,">");
Note that the first replacement operation is an ampersand, as if you tried to replace it later, you would probably veil existing well-cited objects in exactly the same way as ">" .
Also, pay attention to the regular expression 'g' flag, since with it the replacement will take place throughout the text, and not just the first match.
I used regular expressions, but for simple replacements like these, simple strings would be ideal.
You can find the full link for String.replace() here .