fnServeData and xml

fnServeData and xml

bigocbbigocb Posts: 4Questions: 0Answers: 0
edited October 2012 in General
Hello,

I have used Datatables in various configurations for the last 6 months. Now I have the following requirement and I'm stuck. The source file is xml and I would like to use fnServerData to convert it to a usable format:

Now, I know how to parse an xml file in the following way to append to an element, but I'm stuck on how to make the jump to using fnServerData. Has anyone had any experience with this kind of setup?

[code]

$(document).ready(function()
{
$.ajax({
type: "GET",
url: "/rds/reportData/path/Public%20Folders/maps/branches?selection=list1&fmt=simple",
dataType: "xml",
success: parseXml
});
});

function parseXml(xml)
{
$("#example").append('"aaData": [');

$(xml).find("row").each(function()
{
$("#example").append('["'+$(this).find("Address").find("val").text()+',');
$("#example").append($(this).find("Branch__key").find("val").text()+']');

});

}
[code]

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    In fnServerData you should do something like:

    [code]
    success: function ( xml ) {
    callback( parseXml( xml ) );
    }
    [/code]

    Allan
This discussion has been closed.