Link to home
Create AccountLog in
Avatar of ITsolutionWizard
ITsolutionWizardFlag for United States of America

asked on

jquery, loop xml

below codings are working fine but I want to loop the xml child nodes instead of the hard codes.

e.g. i have two items below

               var bondState = $event.find("GeneralInformation").find('State').text();
                var bondName = $event.find("GeneralInformation").find('Name').text();

Is it possible to do something like /node then run for loop to get the children nodes?

Thanks

function fnGetBondNameList() {
    var thisTable = $("#table1").dataTable();
    var selecthtml = '';    
    $.ajax({
        url: "http://localhost:5489/BondList.xml",
        // data: data,
        //type: "POST",
        success: function (response) {
            var $events = $(response).find("Bond");
            $events.each(function (index, event) {
                var $event = $(event),
                addData = [];              
                var bondState = $event.find("GeneralInformation").find('State').text();
                var bondName = $event.find("GeneralInformation").find('Name').text();
                addData.push(bondName);
                addData.push(bondState);
                var line = '<button onclick="funDisplayBondInformation(' + "'" + bondState + "'" + "," + "'" + bondName + "'" + ')" id="btnSubmitSelectedBond" name="btnSubmitSelectedBond" class="btn btn-primary btn-xs">Select</button>';
                addData.push(line);
                thisTable.fnAddData(addData);
            });
         }
    });
}
Avatar of ITsolutionWizard
ITsolutionWizard
Flag of United States of America image

ASKER

Help?
ASKER CERTIFIED SOLUTION
Avatar of ITsolutionWizard
ITsolutionWizard
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer