XML parsing using jQuery
Posted
by lmkk
on Stack Overflow
See other posts from Stack Overflow
or by lmkk
Published on 2010-06-07T08:09:39Z
Indexed on
2010/06/07
9:42 UTC
Read the original article
Hit count: 352
I have the following xml:
<?xml version="1.0" encoding="utf-8"?>
<Area xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Scenes>
<Scene Index="1" Name="Scene1" />
<Scene Index="2" Name="Scene2" />
</Scenes>
</Area>
Which i am trying to parse with jquery:
<script>
$(document).ready(function(){
$.ajax({
type: "GET",
url: "list.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('scenes').each(function(){
$(this).find('scene').each(function(){
var name = $(this).attr('name');
$('<div class="items" ></div>').html('<p>'+name+'</p>').appendTo('#page-wrap');
});
});
}
});
});
</script>
Why is this not working? Help!! first attempt at javascript/jquery This is based on a example I found, but have so far been unable to adapt it to my usage. / Lars
© Stack Overflow or respective owner