views:

44

answers:

1

Hi,

I have a html document which loads an XML document using jQuery

jQuery.ajax( {
    type: "GET",
    url: example.xml,
etc...

When that XML is loaded I want to serialize the entire XML document into a JavaScript array.

How would I do this?

A: 

Something like this?

jQuery.ajax( {
    type: "GET",
    url: "example.xml",
    success: function(data) {
        var results = [];
        // This bit varies depending on your XML structure, but you get the idea
        $(data).find('your_element').each(function(){
            results.push($(this));
        });
    }
 });
heffaklump