Load XML-content into li



I have a ul-list like that:



<ul class="abstimm_ziel"><li>Content 1</li><li>Content 2</li></ul>


And I want to load this xml-files' content:



<?xml version="1.0" encoding="UTF-8"?>
<abstimmer>
<seite id="2">
<klick>3</klick>
<klick>5</klick>
<klick>9</klick>
</seite>
</abstimmer>


into the li-elements according to its order (first node goes into first li-element, second into second...). If there are more nodes then li-elements, then the unnecessary nodes shall be ignored. I try doing this by so:



$(document).ready(function () {
$.ajax({
type: "GET",
url: "abstimmer.xml",
dataType: "xml",
success: function (xml) {
$(xml).find('seite').each(function () {
var klick = $(this).find('klick');
$( ".abstimm_ziel li" ).each(function( index ) {
//And here my brain crashed
})
})
}
})
})


You'll see, that in the line where the real action should start, I broke up. What I tried to do, is walk through the ul-list with each() and put the content of the xml of the appropriate node into the li in it. But I am totally stuck here? What do I need to do now? And is the beginning right at all?


Thanks a lot!


No comments:

Post a Comment