Hello :)
I have a problem with removing elements from document.
Here is the code:
for (int i = 0; i < vec.size(); i++)
if (str.compareTo("NumeroRecibo")== 0) {
List listNodesKey =
xmlPersistente.getDocument().selectNodes(".//ReciboIndemnizacao");
for(int j=0; j<listNodesKey.size(); j++)
{
Node recibo = (Node) listNodesKey.get(j);
if(recibo.selectSingleNode("NumeroRecibo").getText().compareTo(value)==0)
{
xmlPersistente.getDocument().getRootElement().remove(xmlPersistente.getDocument().selectSingleNode(recibo.getUniquePath()+"/Sinistrados"));
break;
}
}
}
Were is the xml.. I want delete the "sinistrados" element where the "numerorecibo" is
equal to a value
<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XML Spy v4.4 U (http://www.xmlspy.com)-->
<Consulta>
<RecibosIndemnizacao>
<ReciboIndemnizacao>
<Sistema>String</Sistema>
<NumeroRecibo>0</NumeroRecibo>
<ValorTotal>00.00</ValorTotal>
<Sinistrados>
<Sinistrado NumeroSinistrado="0"/>
</Sinistrados>
</ReciboIndemnizacao>
<ReciboIndemnizacao>
<Sistema>String</Sistema>
<NumeroRecibo>1</NumeroRecibo>
<ValorTotal>10.00</ValorTotal>
<Sinistrados>
<Sinistrado NumeroSinistrado="0"/>
</Sinistrados>
</ReciboIndemnizacao>
<ReciboIndemnizacao>
<Sistema>String</Sistema>
<NumeroRecibo>3</NumeroRecibo>
<ValorTotal>20.00</ValorTotal>
<Sinistrados>
<Sinistrado NumeroSinistrado="0"/>
</Sinistrados>
</ReciboIndemnizacao>
</RecibosIndemnizacao>
<Mensagens Sucesso="1">
<Mensagem>
<Tipo>0</Tipo>
<Dados>String</Dados>
</Mensagem>
</Mensagens>
</Consulta>
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing
your web site with SSL, click here to get a FREE TRIAL of a Thawte
Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user