Auto formatting XML

Sometimes, I have to read unformatted XML. This always makes me angry, as I have to spend a lot of time pressing the enter key and what not. I found 2 tricks that could help you out.

Trick 1:
Use notepad++

http://notepad-plus-plus.org/

Its a nice text editor, and it add itself to the right-click in windows, so you can open appropriate files with it very easily without changing your default editor.

Trick 2:
First, I just wanted to put everything onto a new line. I took the easy way. Press ctrl+H for Replace, or click Replace in search. Click on the option for “Regular Expressions”. Then, in the Search, put “><" and in the replace, put ">/n<"

Tada!

That still doesn't help the indenting however, so I abandoned this approach.

Trick 3:
This is the best one. In notepad++, click Plugins -> Plugin Manager -> Show Plugin Manager. Scroll down and install “XML Tools”.

Once this is installed, select all on your text that you want to format, then click Plugins -> XML Tools -> Pretty Print (XML Only with Line Breaks)

Ahhh yes, this is what I wanted all along! Hope it helped!

-Kevin

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>