Link to home
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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial