1

我使用 mootools 从网络服务获取响应

  onSuccess: function (responseText) {
      alert(responsetext);
    }

作为我得到的答案

<?xml version="1.0" encoding="utf-8"?>
<int xmlns="http://estimomini">15</int>

我如何只得到字符串 AKA 15 ?

4

2 回答 2

1

如果您知道 XML 文档将始终如下所示,请尝试

onSuccess: function(responseText, responseXML) {
  alert(responseXML.documentElement.firstChild.data);
}
于 2011-10-30T20:22:30.047 回答
0
<script>
window.addEvent('domready', function(){
     var req = new Request({
            url: 'data.xml',
            method: 'get',
            onSuccess: function(responseText, responseXML) {                
                var tempDiv = new Element('div', {html: responseText});
                var myInt = tempDiv.getElement('int').get('text');
                alert(myInt);
            }
        }).send();
});
</script>
于 2011-11-03T17:01:21.280 回答