我有这个 XML 响应:http: //jsfiddle.net/ZeeHv/
我正在尝试使用转储中的信息创建类似的东西:
<UL>
<li>Academic
<ul>
<li>BM</li>
<li>CMTTE</LI>
<li>DM</li>
<li>PM</li>
</ul>
</li>
</ul>
<ul>
<li>ARCHIVE</li>
</UL>
<ul>
<LI>ASSOCIATIONS
<ul>
<li>BM</li>
<li>DM</LI>
<li>PM</li>
</ul>
</LI>
</ul>
最后,XML 可以为我提供我所有站点和子站点的列表:
https://hosted.demo.ca
https://hosted.demo.ca/academic
https://hosted.demo.ca/academic/bm
https://hosted.demo.ca/academic/cmtte
https://hosted.demo.ca/academic/dm
https://hosted.demo.ca/academic/pm
https://hosted.demo.ca/archive
https://hosted.demo.ca/associations
https://hosted.demo.ca/associations/bm
https://hosted.demo.ca/associations/dm
https://hosted.demo.ca/associations/pm
如何浏览这些信息并附加 ul 和 li 标签来创建站点导航菜单?
JS用来获取XML:
function getAllSites(){
$().SPServices({
operation: "GetAllSubWebCollection",
async: true,
completefunc: function(xData, Status){
$(xData.responseXML).find("Web").each(function(){
console.log($(this).attr("Url"));
});
}
});
}