20

At work, we remove newlines from our logs to help prevent log-forging attacks. I have tools that can format XML such as my IDE (NetBeans) and SOAPUI, but they take forever to launch and aren't purpose-built for the task.

I'm looking for an application that:

  • Formats XML
  • Opens quickly
  • Runs on Windows 7
  • Can format XML that is pasted from the clipboard or opened from the file-system.

I'm not looking for a web app that allows me to paste XML into my browser to send to a 3rd party website for formatting and display. I want to keep it all local to my developer workstation.

Nice-to-haves:

  • Doesn't require administrator privileges to install
  • Free and/or open source
3
  • 1
    Care to elaborate on "Formats XML"? Are you wanting a tool that reads the XML and applies nesting and newlines and such?
    – user23
    Commented Feb 7, 2014 at 16:03
  • Yes. I'm looking for an XML beautifier.
    – braveterry
    Commented Feb 7, 2014 at 17:08
  • Microsoft word 2007 used to have a fantastic XML editor, until they god sued for breach of patent. (Someone else patented the idea of a word processor that has a xml editor mode) Commented Feb 8, 2014 at 5:43

5 Answers 5

25

One of the *best simple XML formatting tool for Windows 7* I think it is Notepad++:

Notepad++ Screenshot of editing a file

This tool is so powerful that it should be in the developer current toolbox.

Just look how many formats it recognizes:

Screenshot of available formats

But, the best of all is the fact you can define your own language and apply your own rules!

User Defined Language window

Did I tell you about its search & replace? You can do all kind of replacements grace to the regular expressions and if you have hundreds (!) of open files, you can perform the search and/or replacements in all the documents, in an instant!

Find and Replace window

Don't forget there are a lot of plugins, which can be installed for all kind of jobs!

To conclude, Notepad++ is free and portable (you can use it on a usb stick, just copy it in any folder you want).


EDIT :

As I told you, a lot of Notepad++ functionality is provided by plugins:

Show Plugin Manage Menu link

If you click on each plugin name you'll see a short description about the functionality provided.

To achieve extremely advanced indentation I recommend you to install, at least, the Code alignment, Indent by Fold and XML Tools:

Plugin Manager window

Here's one of the simple indentation, available for XML (but any specialised XML IDE can do that, isn't it?):

Pretty text menu link

But with Indent by Fold you can indent any language, even a User Defined one! (How about the specialised IDEs?)

And now, the finishing indent tool, the Code alignment! Using this, you'll achieve the highest indentation level (indenting by any kind of plain/regular expression):

Align By menu link

2
  • 3
    Yes, I approve totally. I'm using Eclipse and Visual Studio for developing Java, C++ and C# but I always have a Notepad++ with me to do quickly the simple tasks as converting ANSI/UTF-8 or CR/LF/CR-LF.
    – Aubin
    Commented Feb 7, 2014 at 14:35
  • 2
    @Aubin Even the much hyped VS Code still lacks decent XML handling, and all the extensions I tried are either utter trash or just too heavy. Notepad++ sat there in my taskbar for ages, but to this day I didn't know it's got a plugin for XML!
    – sunny moon
    Commented Feb 8, 2022 at 10:39
5

Visual studio has the ability to format XML documents. Simply open the xml document do Edit -> Advanced -> Format Document

If you are using the C# keybindings it's Ctrl + E,D

Not that I am suggesting that visual studio is "simple" or worth installing for this feature only, but in my experience, a lot of devs don't realize this feature exists within the code editor

0
1

SynWrite editor (free, Windows) allows opening and editing of XML (along with many others, e.g. HTML), and it can format XML file.

sample img

To format XML:

  • first, install this Tidy XML plugin by opening plugin's "plugin.Ambyte.TidyXML.zip" file in SynWrite and confirming installation
  • open any XML file (or paste code into new tab)
  • call plugin's menu command "Tools - Plugins - Tidy XML"

The editor can be installed w/o admin rights, to any folder.

I use SynWrite for daily work. Very handy, it's replacement for Notepad++ with Python plugins.

0
1

This is old as hell but I do recommend a web-based solution.

https://xmllint.com

This code runs in your browser and does never send your data anywhere else. Everything remains local on your machine.

How do I know? I built it specifically for that purpose.

0

According to your files' size, you might want to consider vim. It's free and its license is GPL compatible(charityware, if you ask). A portable version is available here, which will let you use it without administrator rights.

Advantages

  • it's quite fast to run, even with big files (I use it to edit 10Gb xml files)
  • it's very powerful. For instance, should you wish to format some freshly pasted xml, you would just need to

    1. install the PrettyXML plugin
    2. open your file with VIM
    3. type :PrettyXML
  • as stated before, it's free.

Drawbacks

VIM is a complex editor to use (on the contrary to other examples, such as NPP). In order to be used correctly, you'll have to learn how to use it (even basic operations such as typing text, or saving your file aren't done the same way as a classical editor). On top of that, the learning curve is quite steep.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.