开发者

How to serialize entire XML document into JavaScript array?

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

jQuery.ajax( {
    type: "GE开发者_JAVA百科T",
    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?


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));
        });
    }
 });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜