I have an nested XML-File like this:
<?xml version="1.0" encoding="utf-8" ?>
<xml>
<section name="Highlights">
<sub name="Highlights" open="Selected Top Events">
<date name="Offroad;Experience" region="Europe" location="Austria / Lech">
<detail from="01.01.2014" to="09.03.2014" thumb="thumb" pic="pic" url="url" text="text"/>
</date>
</sub>
</section>
</xml>
What i want is, i need the values from the Attributes in different HTML-Elements. But how? The Problem is that search for the Element section and then i show the value of the name attribute, but i have also a name attribute in date. Here is my jQuery:
$.ajax({
url: 'data.xml',
dataType: 'xml',
success: function(data) {
//console.log(data);
$(data).find('xml section').each(function() {
var section = $(this).attr('name');
var name = $(this).attr('name');
var user = $(this).find('user name').text();
var sub = $(this).attr('open');
$('.output').append(
$('<div />', {
text: section
})
);
});
},
error: function() {
$('.output').text('XML fail');
}
});