Salve a tutti leggo un file xml con jquery
Il problema è che ci sono piu tag img in uno stesso nodo e quando leggo con
var imgPath=$(this).find('img').text();
mi mette tutto in una stringa tipo:
(photos/image1.jpgphotos/image2.jpgphotos/image3.jpg)
mentre a me serve avere i paths uno per volta...
vi posto il file js e di seguito l'xml
Grazie
Codice PHP:
$(function() {
$.ajax({
type: "GET",
url: "Guest_images.xml",
dataType: "xml",
success: function(xml) {
$('<ul id="menuF">[/list]').appendTo("#gallery");
$(xml).find('category').each(function(){
var nome = $(this).attr('name');
if (nome=="photoGallery1"){
var imgPath=$(this).find('img').text();
$('[*][url="'+imgPath+'"][img]'+imgPath+'[/img][/url]').appendTo("#menuF");
}
});
$('#gallery a').lightBox();
}
});
});
Codice PHP:
<?xml version="1.0" encoding="UTF-8"?>
<gallery>
<category name="photoGallery2">
<img>/image/image_gallery?img_id=14652</img>
</category>
<category name="photoGallery1">
<img>photos/image1.jpg</img>
<img>photos/image1.jpg</img>
<img>photos/image2.jpg</img>
<img>photos/image3.jpg</img>
<img>photos/image4.jpg</img>
<img>photos/image5.jpg</img>
<img>photos/image6.jpg</img>
<img>photos/image7.jpg</img>
</category>
</gallery>