如何仅从responsetext获取数据

时间:2011-10-30 20:15:19

标签: httpwebrequest mootools responsetext

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

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

作为答案我得到了

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

我如何才能获得字符串AKA 15?

2 个答案:

答案 0 :(得分:1)

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

onSuccess: function(responseText, responseXML) {
  alert(responseXML.documentElement.firstChild.data);
}

答案 1 :(得分: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>