Hello, I'm trying to edit an XML file by searching with regular expressions. Once found, the text will be copied, changed and appended at the end (or beginning) of the aforementioned found text.The lines I am looking for have the following format:
<device name="some_device"> .......... </device> "some_device" is a variable set dynamically and known at run time ${old.source.device} as seen bellow. I can find and echo the first line of text with the following syntax, so I know that the text is there: <loadfile property="xml.device.properties" srcFile="${phone.sdk.location}/devices.xml"> <filterchain> <linecontainsregexp> <regexp pattern="(.*)device(.*)${old.source.device}"/> </linecontainsregexp> </filterchain> </loadfile> <propertyregex property="xml.device.properties" input="${xml.device.properties}" regexp="(.*)(<device.*)" override="true" select="\2"/> <propertyregex property="xml.device.properties" input="${xml.device.properties}" regexp="(.*)(\s)" override="true" select="\1"/> <echo>xml.device.properties = ${xml.device.properties}</echo> This will return: <device name="some_device"> What I am interested however is to be able to find the text beginning at this line and ending with <\device>, and then saving it into a local variable as such: <device name="some_device"> .......... </device> Clearly <linecontainsregexp> will only give one line at the time, but I was not able to find a filter that could select several lines at once, using regular expressions. I do not know beforehand how many lines I need to select. Any help will be appreciated. -- View this message in context: http://www.nabble.com/how-to-copy-and-edit-a-section-of-a-text-file-tp19898362p19898362.html Sent from the Ant - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]