View Full Version : Cannot retrieve XML attribute with Ext.DomQuery

16 Feb 2011, 12:26 PM
Hi, guys!
I have following problem: cannot retrieve attribute from XML node with Ext.DomQuery!

I receive following XML from server:

<response status="ok" message="">
<user id="54">
<email>[email protected]</email>

and then I want to retrive next info: first name, email. userId.

I do it with following code (this is success handler in Ext.Ajax.request):

success: function(response, options) {

var xml = response.responseXML;
if (Ext.DomQuery.selectNode('error', xml)) {
// report error here ....
} else if (Ext.DomQuery.selectNode('response[status=ok]', xml)) {
// response is OK, retrieve data
var firstName = Ext.DomQuery.selectValue('first_name', xml);
var email = Ext.DomQuery.selectValue('email', xml);
var userId = Ext.DomQuery.selectValue('user/@id', xml);
// do other stuff

So, this line of code:
var userId = Ext.DomQuery.selectValue('user/@id', xml);
set userId=undefined.

How can I retrieve 'id' attribute from <user> node?


thank you in advance for your help!