好吧,亚伦·迪古拉(Aaron
Digulla)在速度上击败了我。也必须自己弄清楚。我没有使用
cnl.item(i+1)但是
nextSibling():
Element newElement = doc.createElement(stepType); // Element to be inserted newElement.setAttribute("name", stepName);elem.getParentNode().insertBefore(newElement, elem.getNextSibling());
appendChild(Node node) //appends the given child to the end of the list of children
和
insertBefore(Node new, Node child) //inserts "new" into the list, before the 'child' node.
如果有insertAfter(Node new,Node child)方法,这对您来说将非常容易。但不幸的是,没有。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)