Page 1 of 1

Delete all the comments in one go in oXygen Author

Posted: Thu Mar 28, 2019 2:06 pm
by virals
Is there any way to delete all <!-- --> (XML comments) from an XML file(s) in one go?

Re: Delete all the comments in one go in oXygen Author

Posted: Fri Mar 29, 2019 12:52 am
by mdslup
In text mode, you could use a regular expression to do a find/replace, like this:

https://i.imgur.com/Lf1oTSD.png

Check the "Regular expression" box in the bottom right. Then search for:"

<!--.*-->

and replace with nothing.

Re: Delete all the comments in one go in oXygen Author

Posted: Fri Mar 29, 2019 9:06 am
by Radu
Hi,

And if you want to remove all comments in one or multiple files, in the Oxygen main menu Tools->XML Refactoring there is a Delete comments operation which can be performed on multiple files.

Regards,
Radu

Re: Delete all the comments in one go in oXygen Author

Posted: Mon Oct 07, 2019 2:49 pm
by Stereotaxis
Looking forward to see the suggestions of others.

Re: Delete all the comments in one go in oXygen Author

Posted: Mon May 18, 2020 10:28 am
by Romaric
Hello, I read your messages about the tool : XML Refactoring > Delete comments but when I try to use it I don't understand how it's working.

May you tell me more about that ? Is there a tutorial or documentation ?

Best regards

Re: Delete all the comments in one go in oXygen Author

Posted: Mon May 18, 2020 10:38 am
by Radu
Hi,

We have some general documentation about the XML refactoring actions:

https://www.oxygenxml.com/doc/versions/ ... tools.html

but we do not have particular documentation about the action to delete comments.
Once you choose to use the "Delete comments" action, you need to configure an XPath expression for the XML elements from which the comments should be removed. If you want to delete all comments found in the XML file, the "Element" field can take the value *.
Then you choose a set of files over which should be modified and you can preview the changes instead of applying them directly.
If this does not work for you maybe you can tell me step by step what you are doing on your side and what the desired result should be.

Regards,
Radu

Re: Delete all the comments in one go in oXygen Author

Posted: Mon May 18, 2020 3:06 pm
by Romaric
Thanks Radu for your answer,

I am not used to use XML and I don't know XPath but your advice with * works very well.

Now my XML file has many empty spaces or white lines.

Is there a way to delete those empty spaces or to avoid it when I use the tool ?

I would like a clean XML file.

(Sorry for my english I am french).

Thanks.

Regards

Re: Delete all the comments in one go in oXygen Author

Posted: Mon May 18, 2020 3:25 pm
by Radu
Hi,

The refactoring operating which removes XML comments will not format and indent the XML document as a result of the XML comments being removed.
If you want to format and indent the XML files, you can either open them in Oxygen and use the "Format and indent" toolbar action or you can add in the Oxygen Project view a folder containing all the XML files, right click the folder and choose Format and indent files.

Regards,

Radu