1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| /*
<directories>
<dir name="1" depth="0">
<file>
<name>h _1.JPG</name>
<source>http://localhost/devMediasService/photos/h _1.JPG</source>
<size>609612</size>
</file>
<file>
<name>IMG_0206.JPG</name>
<source>http://localhost/devMediasService/photos/IMG_0206.JPG</source>
<size>764395</size>
</file>
</dir>
<dir name="ooo" depth="0">
<file>
<name>IMG_0220.JPG</name>
<source>http://localhost/devMediasService/photos/ooo/IMG_0220.JPG</source>
<size>660493</size>
</file>
<file>
<name>IMG_0228.JPG</name>
<source>http://localhost/devMediasService/photos/ooo/IMG_0228.JPG</source>
<size>661391</size>
</file>
</dir>
</directories>
dir (name, depth) = ( 1 , 0 )
file name = h _1.JPG
file source = http://localhost/devMediasService/photos/h _1.JPG
file size = 609612
file name = IMG_0206.JPG
file source = http://localhost/devMediasService/photos/IMG_0206.JPG
file size = 764395
dir (name, depth) = ( ooo , 0 )
file name = IMG_0220.JPG
file source = http://localhost/devMediasService/photos/ooo/IMG_0220.JPG
file size = 660493
file name = IMG_0228.JPG
file source = http://localhost/devMediasService/photos/ooo/IMG_0228.JPG
file size = 661391
*/
$.get("XML-1.xml", function(data){
$(data).find("directories").children().each(function(i, item){
console.log("dir (name, depth) = (", $(item).attr("name"), ", ", $(item).attr("depth"), ")");
$(item).children().each(function(j, jtem){
console.log("file name = ", $(jtem).children("name").text());
console.log("file source = ", $(jtem).children("source").text());
console.log("file size = ", $(jtem).children("size").text());
});
});
}).error(function(){
console.log(arguments);
}); |
Partager