Question

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 ?

Was it helpful?

Solution

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

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

OTHER TIPS

<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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top