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));
});
}
});
精彩评论