//如果是初次加载就只读出一级节点
Element rootEle = dom.getRootElement();
//点击父节点获取所有的子节点
if(!("0").equals(topicId)){
//获取当前选定的父节点
Element node = (Element) rootEle.selectSingleNode(".//topic[@id='" + topicId + "']");
rootEle = node;
}
return NaviUtil.getUl(rootEle);
Element rootEle = dom.getRootElement();
//点击父节点获取所有的子节点
if(!("0").equals(topicId)){
//获取当前选定的父节点
Element node = (Element) rootEle.selectSingleNode(".//topic[@id='" + topicId + "']");
rootEle = node;
}
return NaviUtil.getUl(rootEle);
本文介绍了一种通过DOM操作获取XML文档中特定节点的方法。针对不同情况(如初次加载或点击父节点),文章详细展示了如何选取并返回相应的节点及其子节点。
7212

被折叠的 条评论
为什么被折叠?



