Here's an example of getting an XML and parsing it via jQuery:
$.ajax({
type: "POST",
url: "some.xml",
dataType: "xml",
success: function(xml) {
var node = $(xml).find('node');
var attribute = $(xml).find('node').attr("attribute");
//TODO: do something with data
}
});
You might also want to use $.each()
for iterating through element collections.
Edit: and here's how to create some checkboxes assuming the returned XML looks like this:
<?xml version="1.0"?>
<RootElement>
<CheckBox name="checkbox1">checked</CheckBox>
<CheckBox name="checkbox1">checked</CheckBox>
<CheckBox name="checkbox1"></CheckBox>
<CheckBox name="checkbox1"></CheckBox>
<CheckBox name="checkbox1">checked</CheckBox>
</RootElement>
The js would look like this:
$(xml).find('CheckBox').each(function(){
var value = $(this).text(); // get the value
var name = $(this).attr("name"); //get the name attribute
$("#parent_div").append( //append to some parent container
$("<input/>") // a new input element
.attr("type", "checkbox") //of type checkbox
.attr("name", name) // with given name
.attr("checked", value) // checked="checked" or checked=""
)
});