Hi list,

I've run up against a small problem processing my ajax response using
jQuery.

Suppose I have this xml returned from a post or ajax call:

<?xml version="1.0" ?>
<!DOCTYPE sebResponse>
<sebResponse>
<element1>some text</element1>
<element2>more text</element2>
</sebResponse>

The key thing here is that I don't know what elements will be in
<sebResponse>; it could be as shown, or there could be a hundred
different elements.

I'd like to iterate through this xml (which is contained in an object
called data, returned from the ajax call) to get the element tag-name
and the element contents. I can get the contents like this:

$("sebResponse",  data).children().each(function() {
      alert ("element content is: " + $(this).text());
});

This gives me access to the content of each element - "some text",
"more text", but I also need the element name in each case.

Can anyone tell me how to get that?

best regards,

Seb James

Reply via email to