So there’s a messy XML file where all white spaces between tags have been stripped, so it’s a valid XML file but it’s somewhat unreadable.
I press the magic Ctrl+K, D, and the file is beautifully formatted.
I edit it, and then I want to put it back into the compressed, hardly readable state, removing all whitespaces between the tags. How do I do that in VS 2008? I looked though the list of all available commands but couldn’t find any.
Using Notepad++
I recommend you get Notepad++ and install the XML Tools plugin. The
Plugins > XML Toolsmenu contains aLinarize XMLitem that does exactly what you want.Using Visual Studio
You could do a Find & Replace using a regular expression.
First remove all the whitespace preceding any XML tags using these search criteria:
Then remove all the whitespace preceding any text or attributes:
Note: There should be a space in front of
\1.Disclaimer: This method may not be completely accurate, so make sure to double-check the result!