我有一个需要使用jQuery解析的XML.我理解如何获得第一级站点地图节点,但我的一些节点深度为3或4级.我似乎无法超越2级.这是我的XML和我的代码.我很累,把它输出到一个列表,能够在我正在处理的其中一个网站上悬停jQuery.请有人帮忙.
<siteMapNode url="#" title="root" description="">
<siteMapNode url="http://qswebdev02:2010/Category/4-gear.aspx" title="Gear" description="Gear">
<siteMapNode url="http://qswebdev02:2010/Category/5-snow.aspx" title="Snow" description="Snow">
<siteMapNode url="http://qswebdev02:2010/Category/6-bags.aspx" title="Bags" description="Bags" />
</siteMapNode>
<siteMapNode url="http://qswebdev02:2010/Category/7-surf.aspx" title="Surf" description="Surf">
<siteMapNode url="http://qswebdev02:2010/Category/8-towels.aspx" title="Towels" description="Towels" />
</siteMapNode>
</siteMapNode>
</siteMapNode>
Run Code Online (Sandbox Code Playgroud)
-
$(document).ready(function () {
$.ajax({
url: 'nav.xml',
type: 'GET',
dataType: 'xml',
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert('Error: ' + textStatus + ", " + errorThrown);
},
success: function (xml) {
var count = 0;
$(xml).find('siteMapNode').each(function (e) {
//category
var url = $(this).attr('url');
var title = $(this).attr('title');
var descr …Run Code Online (Sandbox Code Playgroud)