Thomas Thomas wrote:
Hi,

in an XML file, I have the following type of records :

<startlist>
 <start parse="true" index="true">http://intranet.lu.anonyme1.bank</start>
 <start parse="true" index="true">http://intranet.lu.anonyme2.bank</start>
</startlist>

I want to delete all the start elements, and add new start elements.
I try this :


           FileConfiguration writer = new XMLConfiguration(path);
           writer.setAutoSave(true);

           writer.clearProperty("startlist.start");


But I have then the following :

<startlist>
 <start index="true" parse="true"/>
 <start index="true" parse="true"/>
</startlist>

As u can see the elemnt is still there, it just deleted the content.

How can I delete the elements totally?
Thank u.


The clearProperty() method only removes the direct value of the specified key, which in your case is the text value of the <start> element; the attributes remain.

For removing complete sub trees (i.e. everything below the start element, including its attributes and further sub elements) HierarchicalConfiguration has the clearTree() method. If you cast your configuration to a HierarchicalConfiguration object, you can try this method.

HTH
Oliver

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to