ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ca_iancu <ca_ia...@hotmail.com>
Subject Re: how to copy and edit a section of a text file
Date Fri, 10 Oct 2008 00:11:18 GMT

>you mean copy one name attribute

No, I mean copy the entire section as written down before: from <device name
.... to </device>. I keep the old section, then I append the new one which
is almost identical but not quite. If you look again at the code, you will
see that the second xml file (the one I would like to get) is different than
the first one. Here's another attempt, where device1 is duplicated and it
becomes device2.They are independent entities now. Thank you.


>  <?xml version="1.0" encoding="UTF-8"?>
> <root>
> 	<device>
> 	    <device name="device1">
> ..........a number of lines of properties here (irrelevant, unchanged)
>      </device> 
> 	</device>
> </root>

> to the following:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <root>
> 	<device>
> 	    <device name="device1">
> ..........a number of lines of properties here (irrelevant, unchanged)
>      </device> 
>      
>      <device name="device2">
> ..........a number of lines of properties here (irrelevant, unchanged)
>      </device> 
> 	</device>
> </root>



Gilbert Rebhan wrote:
> 
> ca_iancu schrieb:
>>> Can you provide a little more details, xmlfile how it is and how it
>> More details, certainly! I need to find/read/duplicate a section of an
>> xml
>> file, then append it and make a simple change to the added section. I
>> need
>> to go from:
>> 
>>  <?xml version="1.0" encoding="UTF-8"?>
>> <root>
>> 	<device>
>> 	    <device name="some_device">
>> ..........a number of lines of properties here (irrelevant, unchanged)
>>      </device> 
>> 	</device>
>> </root>
> 
> hm, still not clear for me ...
> 
>> to the following:
>> 
>> <?xml version="1.0" encoding="UTF-8"?>
>> <root>
>> 	<device>
>> 	    <device name="some_device">
>> ..........a number of lines of properties here (irrelevant, unchanged)
>>      </device> 
>>      
>>      <device name="some_other_new_device">
>> ..........a number of lines of properties here (irrelevant, unchanged)
>>      </device> 
>> 	</device>
>> </root>
> 
> you mean copy one name attribute
> <device>
>   <device name="attribute to copy">
>   <device name="...">
> ...
> </device>
> 
> and append it as
> <device>
>   <device name="copy of attribute to copy">
>   <device name="...">
> ...
> </device>
> 
> ??
> 
>> That's it. The problem for me is: copy the text in a variable, then
>> append
>> right after the end of the existing text. I briefly looked at the xmltask
>> but it seemed like what it does is read an xml file, and then it sets the
>> existing fields to ant properties. It didn't seem like it's something I
>> could use for text processing. 
> 
> oh, the xml task is great for editing xml files, that's what
> xmltask is made for ;-)
> 
> Regards, Gilbert
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-copy-and-edit-a-section-of-a-text-file-tp19898362p19909746.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message