function FillXMLdataInDiv(Div, XMLNodes) { var tempXML; //Fill XML in controls XMLNodes.each(function() { selectedNodeName = $(this)[0].nodeName; if (selectedNodeName.indexOf(_XML) != -1) { FillXMLdataInDiv(Div, $(text2xml($(this).text())).find(ROOT).children()); return; } var _control = $(ControlsDataXML).find(selectedNodeName).attr('control'); // extract control-name from template xml var control = Div.find(. + _control); //find control from Div if (control.length > 0) { if (control[0].type == 'radio' || control[0].type == 'checkbox') { control.parent().find(input[@value=' + $(this).text() + ']).attr(defaultChecked, checked); control.parent().find(iput[@value=' + $(this).text() + ']).attr(checked, checked); } else if ($(control).hasClass(hdnXML)) { tempXML = ''; $(this).children().each(function() { if ($(this)[0].xml != undefined) { tempXML = tempXML + $(this)[0].xml; } else { tempXML = tempXML + (new XMLSerializer()).serializeToString($(this)[0]) } }); control.val(tempXML); } else { (control[0].nodeName == 'INPUT' || control[0].nodeName == 'SELECT' || control[0].nodeName == 'TEXTAREA') ? control.val($(this).text()) : control.text($(this).text()); //Check whether it's a textbox/li } } }); //close each element }