commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@oliver-heger.de>
Subject Re: Jakarta Configuration Question
Date Mon, 27 Nov 2006 21:03:02 GMT
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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message