And as I said, encodeURI, encodeURIComponent, and escape are all completely wrong solutions, as they convert (for example) < to %3C instead of to the < that is required by XML.
And I don't think you would want Object.HTMLEncode, in any case. Since you say you want to produce XML from (presumably) a tree of objects, you would presumably do it with an object-to-xml method, and I think you will find that all browser can do that for you.
For Internet Explorer:
var string = xmlNode.xml;
var string = (new XMLSerializer()).serializeToString(xmlNode);
where of course xmlNode can be a root node of an entire tree to be converted to XML string.
And I'm pretty darned sure that either of those will happily handle encoding the needed entities.