ITsolutionWizard
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("GeneralInform ation").fi nd('State' ).text();
var bondName = $event.find("GeneralInform ation").fi nd('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("GeneralInform ation").fi nd('State' ).text();
var bondName = $event.find("GeneralInform ation").fi nd('Name') .text();
addData.push(bondName);
addData.push(bondState);
var line = '<button onclick="funDisplayBondInf ormation(' + "'" + bondState + "'" + "," + "'" + bondName + "'" + ')" id="btnSubmitSelectedBond" name="btnSubmitSelectedBon d" class="btn btn-primary btn-xs">Select</button>';
addData.push(line);
thisTable.fnAddData(addDat a);
});
}
});
}
e.g. i have two items below
var bondState = $event.find("GeneralInform
var bondName = $event.find("GeneralInform
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("GeneralInform
var bondName = $event.find("GeneralInform
addData.push(bondName);
addData.push(bondState);
var line = '<button onclick="funDisplayBondInf
addData.push(line);
thisTable.fnAddData(addDat
});
}
});
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER