sylvain + whissell = geek

From C# to pin sharp (and everything in between).

Using Notepad++ To Quickly Format XML

My favorite way to quickly format a given chunk of XML is to use Notepad++ and the XML Tools plugin.  You can get Notepad++ here.  And the XML Tools plugin is here (you’ll have to wait a few seconds before the download starts).

Installing Notepad

(the following instructions are based on Notepad++ v5.9.4 and my differ in later versions)

1) Choose your language:

image

2) Click Next:

image

3) Agree to the License Agreement:

image

4) Choose where you want to install the files:

image

5) Choose what options you want to install (I simply use the defaults):

image

6) Choose the final set of options.  I check the first one because I like having applications keep their data in their own installation directory:

image

7) Click Install:

image

8) Click Finish and you’re done!

image

 

Settings In Notepad++

There are a few settings that I always set that (I find) make life more convenient (but that’s just me).

Under Settings | Preferences:

image

On the “General” tab, I check “Show close button on each tab”.

image

On the “MISC.” tab, I uncheck “Remember current session for next launch” because I always want Notepad++ to open with a new blank document.

image

 

Installing the XML Tools

If you run Notepad++ and look in the Plugins menu, you’ll see that the XML Tools aren’t there:

image

1) Download the XML tools from here.

2) Unzip the file and copy the XMLTools.dll to the Notepad++ plugins folder (in the example above: C:\Program Files (x86)\Notepad++\plugins):

image

3) Re-start Notepad++ and you should now see the XMLTools appear in the Plugins menu:

image

When you click on “How to use…” you’ll get the following:

image

4) I’ve just tried (2011/10/20) following those links and the first one doesn’t work and the 2nd one just takes you to a directory listing. So, I’ve uploaded the zip file to my site and you can download the missing lib files from here.

5) Unzip the ext_libs.zip file and then copy the unzipped DLLs to the Notepad++ installation directory (in the example above: C:\Program Files (x86)\Notepad++):

image

6) Re-start Notepad++ and you should finally see the proper XML Tools menu:

image

The feature I use the most is “Pretty print (XML only – with line breaks)”.  This will format any piece of XML with all the proper line spacing.

Start with:

image

After doing Ctrl+Alt+Shift+B:

image

Sweet!

  • Mike Miller says:

    Thanks for the help – I played around with the Tidy stuff and all I got was exceptions. Read your article and bang – Done!

    August 31, 2011 at 15:59
  • geek says:

    No worries at all. Glad it was useful!

    August 31, 2011 at 16:43
  • Ty Pillet says:

    I can’t figure out how to set this up. I just get a “how to use” option which then produces the error above, but I can’t figure out what to do next. Please can you give us more details? I appreciate it. Thank you for this in formation.

    JV

    October 20, 2011 at 11:43
  • geek says:

    Hey Ty,

    I originally wrote this well over a year ago. I just tried the links for the missing lib files and they seem to be broken. I’ve uploaded the zip file to my site and I’ve also totally re-written this post with detailed instructions. It should be much clearer now on how to set this up.

    Cheers.

    October 20, 2011 at 15:31
  • Prathap says:

    Very nice post… Was very useful.

    October 25, 2011 at 04:39
  • Prady says:

    Super useful info…worked like a gem!!

    November 9, 2011 at 11:12
  • Divya B Rajendra says:

    very helpful post… Thank you very much… !! :)

    November 16, 2011 at 04:19
  • bfoxx says:

    Thanks Man. Very Helpful

    December 1, 2011 at 09:35
  • Charlie says:

    Thanks – works exactly as you say – proper job!

    December 1, 2011 at 11:44
  • JK says:

    Great work! The picture & short comments are very good explanation. It is a spoon feed for anyone. Thank you for your work. Blessings.

    December 7, 2011 at 09:31
  • Spork says:

    Thanks for writing this post. I wanted to quickly format XML messages from log files and the other options I tried didn’t work or weren’t compatible with my app version (see http://stackoverflow.com/questions/193728/free-xml-formatting-tool and http://stackoverflow.com/questions/412427/auto-indent-in-notepad). Once all the proper libs were available the XMLTools plugin did exactly what I wanted!

    December 16, 2011 at 11:54
  • Greg says:

    Good contribution mate.
    Thanks

    January 1, 2012 at 12:09
  • harini says:

    great!
    thanks

    January 12, 2012 at 04:04
  • harini says:

    great job
    thanks, it’s very useful

    January 12, 2012 at 04:22
  • Petar Repac says:

    Tnx

    February 1, 2012 at 10:06
  • bob9 says:

    Awesome Effort Champ..

    February 4, 2012 at 09:43
  • prabu says:

    Thanks..very useful

    February 10, 2012 at 02:38
  • gimme says:

    Awesome stuff – only wish I found this post months ago!

    February 17, 2012 at 00:34

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

*