Dom4j怎么获取xml文件中某元素所在的行号?

Dom4j怎么获取xml文件中某元素所在的行号


qq_花开花谢_0
浏览 1550回答 4
4回答

狐的传说

dom4j中,使用Element.attributes方法可以获取到节点的属性,而使用elements则可以获取相应的子节点比如:Element root = doc.getRootElement();List attrList = root.attributes();for (int i = 0; i < attrList.size(); i++) {//属性的取得Attribute item = (Attribute)attrList.get(i);System.out.println(item.getName() + "=" + item.getValue());}List childList = root.elements();for (int i = 0; i < childList.size(); i++) {//子节点的操作Element it = (Element) childList.get(i);//对子节点进行其它操作...}
打开App,查看更多内容
随时随地看视频慕课网APP