为了诚实,我用 t子仍然使用XML。
我有一点XML(下文):
<folder title="Home">
<item title="Welcome" />
<folder title="My Photos">
<folder title="Holidy">
<item title="Photo 1" />
<item title="Photo 2" />
<item title="Photo 3" />
<item title="Photo 4" />
<item title="Photo 5" />
</folder>
<folder title="Christmas">
<item title="Photo 1" />
<item title="Photo 2" />
<item title="Photo 3" />
<item title="Photo 4" />
<item title="Photo 5" />
<item title="Photo 6" />
<item title="Photo 7" />
<item title="Photo 8" />
</folder>
<folder title="Zoo">
<item title="Photo 1" />
<item title="Photo 2" />
<item title="Photo 3" />
<item title="Photo 4" />
</folder>
</folder>
<folder title="My Videos">
<item title="Movie 1" />
<item title="Movie 2" />
<item title="Movie 3" />
<item title="Movie 4" />
<item title="Movie 5" />
<item title="Movie 6" />
<item title="Movie 7" />
<item title="Movie 8" />
</folder>
<folder title="My Audio">
<folder title="Artist 1">
<folder title="Album 1">
<item title="Track 1" />
<item title="Track 2" />
<item title="Track 3" />
<item title="Track 4" />
<item title="Track 5" />
<item title="Track 6" />
<item title="Track 7" />
</folder>
<folder title="Album 2">
<item title="Track 1" />
<item title="Track 2" />
<item title="Track 3" />
<item title="Track 4" />
<item title="Track 5" />
<item title="Track 6" />
<item title="Track 7" />
<item title="Track 8" />
</folder>
</folder>
<folder title="Artist 2">
<folder title="Album 1">
<item title="Track 1" />
<item title="Track 2" />
<item title="Track 3" />
<item title="Track 4" />
<item title="Track 5" />
<item title="Track 6" />
<item title="Track 7" />
</folder>
</folder>
<folder title="Podcasts">
<item title="Track 1" />
<item title="Track 2" />
<item title="Track 3" />
<item title="Track 4" />
<item title="Track 5" />
<item title="Track 6" />
<item title="Track 7" />
<item title="Track 8" />
</folder>
</folder>
</folder>
并且我希望按此顺序排列(以下简称)
<div class="entry">
<p><span class="links">Sub-directory</span></p>
<p><span class="files">File One</span></p>
<p><span class="files">File Two</span></p>
<p><span class="files">File Three</span></p>
<p><spanclass="files">FileFour</span></p>
<p><spanclass="files">FileFive</span></p>
<p><span class="files">File Six</span></p>
</div>
and I want to navigate inside... I have understand how to load the XML but I didn t understand how to put inside the span TAG the title text. And when naveigate into "My Photos"... how to see the child contents...
事先得到帮助。
EDIT:
The jQuery (below):
$.ajax({
type: "GET",
url: "content.xml",
dataType: "xml",
success: function (xml) {
$(xml).find( Home ).children().each(function () {
var title_text = $(this).attr( title );
var spanFiles = $( span.files );
spanFiles
.html(title_text)
.appendTo( div.entry );
});
}
});
但不从事工作......