how to get only data from responsetext

742 Views Asked by At

i use mootools to get response from a webservice

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

as answer i get

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

how do i get only the string AKA 15 ?

2

There are 2 best solutions below

2
On BEST ANSWER

If you know that the XML document will always look like this, try

onSuccess: function(responseText, responseXML) {
  alert(responseXML.documentElement.firstChild.data);
}
0
On
<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>