没有原型没有解析 XML 的本机方式。您也不能使用 $(xml) 扩展 xml,然后使用 .next()、.select() 等遍历 DOM。
这是我最近在一个项目中从拼写检查结果中手动解析一些 XML 的示例。应该让你开始。
parseResults: function(results) {
var c = results.responseXML.getElementsByTagName('c');
var corrections = $A(c);
if(!corrections.size()){
this.link.insert({ after: '<span class="spellCheckNoErrors">No spelling errors</span>' });
(function(){ this.link.next().remove(); }.bind(this)).delay(1);
return null;
}
this.res = $A();
corrections.each(function(node){
sugg = node.childNodes[0].nodeValue;
offset = node.attributes[0].nodeValue;
len = node.attributes[1].nodeValue;
this.res.push(
$H({
word: this.text.substr(offset, len),
suggestions: sugg.split(/\s/)
})
);
},this);
this.overlay();
},