I have a requirement to display data from a xml file from server (path to file something like files/client.xml
) into a html table or datagrid, which plugin or rathe
Basically, you can read the XML DOM just as you read the HTML DOM, using jQuery selectors. So in your XML example, if you want to do something specific with each
element - say, add the contents of it's mount
attribute to an unordered list, you could do something like this:
$(xml).('file').children().each(function() {
var fileElem = this; // save the instance for closure
$('ul#theList').append($('- ').text(fileElem.attr('mount'));
});
You can get the XML contents with AJAX, using jQuery's built-in AJAX API:
$.ajax({
type: "GET",
url: "your.xml",
dataType: "xml",
success: function(xml) {
// Insert the previous code snippet here
}
});
I got all of this from this tutorial, so it might be helpful for you too. Note: This was the very first hit on Google for "jquery xml"...