在jdom中插入节点有哪几种方法?
怎么实现在指定位置进行灵活的插入呢?
谢谢
Node insertBefore(Node newChild, Node refChild)
Inserts the node newChild before the existing child node refChild.
这是 org.w3c.dom.Node 类型的一个方法,可以在某个指定的节点前插入新节点。jdom 没用过,应该有类似方法。
Each of these methods adds the new code to the end of the Element list.To insert a node in a different position,ull have to retrieve the List object itself.For example,the following code fragment creats the same channel element by inserting all the child nodes in reverse order at the beginning of the list using the add(int index,object o) method:
Element channel = new Element("channel");
Element link = new Element("link");
Element description = new Element("description");
List content = channel.getContent();
content.add(0,description);
content.add(0,link);