Java XML RemoveChild的问题

Java XML RemoveChild的问题,java,xml,Java,Xml,我有以下代码: try { Builder builder = new Builder(); Document doc = builder.build(Config.PATH +"incasation.xml"); Element root = doc.getRootElement(); Elements childs = root.getChildElements("locations"); int nodeToDelete = 0;

我有以下代码:

try {
    Builder builder = new Builder();
    Document doc = builder.build(Config.PATH +"incasation.xml");

    Element root = doc.getRootElement();    
    Elements childs = root.getChildElements("locations");

    int nodeToDelete = 0;
    for(int i=0; i < childs.size(); i++)
    {
        Element child = childs.get(i);
        System.out.print(child.getFirstChildElement("name").getValue());
        System.out.print(" - ");
        System.out.print(getLocationName().getText());
        System.out.print(" - ");
        System.out.println(child.getFirstChildElement("name").getValue().equals(getLocationName().getText()));

        if(child.getFirstChildElement("name").getValue().equals(getLocationName().getText()))
        {
            nodeToDelete = i;
        }
    }

    root.removeChild(nodeToDelete);
    Simplexml sx = new Simplexml();
    sx.save(root, Config.PATH +"incasation.xml");
}
catch(Exception e) {}

编译时错误
org.w3c.dom.Element#removeChild
需要一个
节点
对象,而不是一个整数值。或者您是否使用另一个名为
Element
的类?

请解释
不起作用
。。。另外,在将其传递给removeChild之前,
nodeToDelete的值是多少?我在
org.w3c.dom.Element
中看不到任何带有removeChild(int)签名的方法,元素对象的类是什么?类是XOM,nodeToDelete int I到n,并且
它不工作
我的意思是没有被删除
root.removeChild(nodeToDelete);         
Element root2 = (Element) root.copy();

Simplexml sx = new Simplexml();
sx.save(root2, Config.PATH +"incasation.xml");