Я не понял как ваш метод применить.

Код:
XML.prototype.toObject = function () {
var xparse = function (n) {
var o = new String (n.firstChild.nodeValue), s, i, t;
//trace (o)
for (s = (o == "null") ? n.firstChild : n.childNodes[1]; s != null; s = s.nextSibling) {
if (s.childNodes.length > 0) {
t = arguments.callee (s);
} else {
t = new String (s.nodeValue);
//явно задан тип String
}
for (i in s.attributes) {
t[i] = s.attributes[i];
}
if (o[s.nodeName] != undefined) {
if (!(o[s.nodeName] instanceof Array)) {
o[s.nodeName] = [o[s.nodeName]];
}
o[s.nodeName].push (t);
t.xmlCount = s.childNodes.length;
} else {
o[s.nodeName] = t;
}
o[s.nodeName].xmlCount = s.childNodes.length;
}
return o;
};
return xparse (this);
};
s = '<?xml version="1.0" ?><xmltest><num>500</num><txt attributeExample="Node 2 attribute"><some>777</some><thing>qwerty</thing></txt></xmltest>';
xml = new XML (s);
trace (xml.toObject ());
и простой вызов возращает null.