Wrong forum. This should be in the general JavaScript forum, I think. It has nothing to do with either JSON or the DOM.
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.
Code:
For Internet Explorer:
var string = xmlNode.xml;
For others:
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.