[oXygen-user] Easy Way to Delete Entire Elements Using Map-Based Search and Replace?

Adrian Buza
Thu Sep 16 09:48:35 CDT 2010


Hi Eliot,

The current implementation of Find/Replace in Files can't handle 
multi-line matches. We are currently working on this for v12.1 or v12.2 
depending on how time allows it.

Even so, you should be able to remove intervals mapped by an XPath 
expression by using Find/Replace in Files.
Try this in Find/Replace in Files:
1. In "Text to find" use ".*\n?"(match any string, also the newline 
character if it exists)
2. Enable the "Regular expression" option.
3. Specify the XPath expression. e.g. //myelement[@myid='myvalue']
4. Disable "XML search options"(unless you want to fine-tune what you 
need to remove from inside the XPath interval)
5. Leave the "Replace with" field blank.
6. Make sure you apply it on the appropriate scope and have the right 
file filters.
7. Test it with "Find All". You will obtain a list of the strings or 
full lines that will be removed.
8. If it seems right Open Find/Replace in Files again, double check 
everything(especially the "Text to find" and "Scope") and use 'Replace All'.

This only leaves behind the indent of the original element. I guess the 
XPath could be further tuned to also catch that in the matched interval.

Regards,
Adrian

Adrian Buza
oXygen XML Editor and Author support
Tel: +1-650-352-1250 ext.202
Fax: +40-251-461482

http://www.oxygenxml.com

Eliot Kimber wrote:
> I have the situation where I want to delete elements in a bunch of topics
> where I can reliably find the elements (e.g., via XPath or regex).
>
> But there doesn't appear to be an obvious way to do this.
>
> Have I missed something?
>
> In my particular case the elements involved will have attributes with unique
> values or will span multiple lines.
>
> Cheers,
>
> E.
>
>   




More information about the oXygen-user mailing list