Так что мне нужно 3 деления. когда я нажимаю на каждую ссылку , отображается соответствующий div с информацией, поступающей из файла XML.
Вот файл XML:
<dynamic_div>
<div set="1">
<p>Lorem ipsum dolor sit amet, consecter adipiscing elit. Ut ac ipsum et metus cursus feugiat nec at purus. In imperdiet lectus eu metus mollis nec mollis sem tincidunt.</p>
<p>Vestibulum lortis est eu ante bendum convallis ornare dolor consectetur. Proin gravida turpis non odio lacinia sit amet elementum justo dapibus.</p>
<p>Duis eget lacus id lectus adipiscing bibendum at ut dolor. Sed laoreet leo id nunc elementum a rhoncus leo bibendum.</p>
</div>
<div set="2">
<image>
<name>Image</name>
<source>/img/jpeg.jpg</source>
<alt>some alt info</alt>
</image>
</div>
<div set="3">
<links>
<title>Web Links</title>
<link>
<name>Site 1</name>
<url>http://www.w3.org</url>
</link>
<link>
<name>Site 2</name>
<url>http://www.site.com</url>
</link>
<link>
<name>Site 3</name>
<url>http://www.site.net</url>
</link>
<link>
<name>Site 4</name>
<url>http://www.site.com</url>
</link>
<link>
<name>Site 5</name>
<url>http://www.site.com</url>
</link>
</links>
</div>
</dynamic_div>
так что в настоящее время это то, что у меня есть для jQuery. Любые идеи о том, как это можно упростить, чтобы делать то, что мне нужно?
$(function(){
$.ajax({
type: "GET",
url: "dev_test.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('content').each(function() {
var set = $(this).attr('set');
if(set == 1)
{
var words = $(this).find('p').text();
$('<p>').html(words).appendTo('#set_1');
}
if(set == 2)
{
var name = $(this).find('name').text();
var img = $(this).find('source').text();
var alt = $(this).find('alt').text();
$('<img />').attr('src',img).attr('alt',alt).attr('title',name).appendTo('#set_2');
//('<img />').data(words).appendTo('#set_2');
}
if(set == 3)
{
var words = $(this).find('p').text();
$('<p>').html(words).appendTo('#set_3');
}
});
}
});
});