这是我的代码:
SAXBuilder builder = new SAXBuilder();
File xmlFile = new File( "fichadas.xml" );
try
{
Document fichero = (Document) builder.build( xmlFile );
Element rootNode = fichero.getRootElement();
for (Element tabla : rootNode.getChildren( "fichada" )) {
String term = tabla.getChildTextTrim("N_Terminal");
String tarj = tabla.getChildTextTrim("Tarjeta");
String fech = tabla.getChildTextTrim("Fecha");
String horaEnXML = tabla.getChildTextTrim("Hora");
String caus = tabla.getChildTextTrim("Causa");
//HERE I WANT TO DELETE THE PREVIOUS NODE NOT THE ACTUAL
tabla.detach();
}
//OVERWRITING THE DOCUMENT
try (FileOutputStream fos = new FileOutputStream("fichadas.xml")) {
XMLOutputter xmlout = new XMLOutputter();
xmlout.output(fichero, fos);
}
} catch ( IOException io ) {
System.out.println( io.getMessage() );
} catch ( JDOMException jdomex ) {
System.out.println( jdomex.getMessage() );
}
我有一些问题,我认为如果我从实际节点分离我无法进入下一个节点,那么我正在尝试找到删除前一个节点并删除和循环的乞求的方法,如何我可以做吗?