I am having trouble parsing specific data using jquery. I have tried a few tutorials and samples online but I don't seem to have any luck with the way my data is formatted.
If I have xml data as follows:
<links total="2">
<link id="1">
<title>whatwhat</title>
<url>http://google.com</url>
<img>1c9a871e2e074616ff45e26d8c2f7715.gif</img>
</link>
<link id="2">
<title>test445</title>
<url>http://yahoo.com</url>
<img>3233c3b40f8db13274c21b6f78f04d06.gif</img>
</link>
</links>
How would I go about extracting all the elements?
So far I tried this to get the id but it did not work:
<script>
$(document).ready(function(){
$.ajax({
type: "GET",
url: "http://mysite.com/where/data.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('link').each(function(){
var id = $(this).attr('id');
$('<div class="items" id="link_'+id+'"></div>').html('<a href="#">link</a>').appendTo('#page-wrap');
});
} }); });