0

I have several medium sized (1 MB) xml file that I frequently need to format. (I am getting them from a program that outputs them with no indentation).

I am looking for someway to quickly and easily format the files locally on my machine.

I have been using http://xmlindent.com/ to format them but

  • I don't like uploading my content to a third party site
  • its a pain in the butt to upload the file, copy it from the page, open a new file paste the results in ...

I know that eclipse has a xml formatter but it is choking because the file size is too big.

My primary editor for xml is vim.

3 Answers 3

1

The best solution I found was to use Notepad++. Under:

Menu: TextFX -> TextFX HTML Tidy -> Tidy: Reindent XML

Note: This method will only work under Windows Vista & Windows 7 when Notepad++ is being run as admin (right click -> Run as administrator). When being run as a regular user it will silently fail.

Sign up to request clarification or add additional context in comments.

Comments

1

XML-Starlet does it on any Unix and even on a Windows Commandline

from the manual:

xml fo your_malformated_file.xml

and in vim you just do

:%!xml fo

Comments

0

If all you need is simple fixed formatting (newline after each close tag, indent each enclosed tag a fixed number of spaces/tabs), you can probably write a simple program yourself. You could probably even write a Vim macro to do it.

4 Comments

Why reinvent the wheel? I am sure that this must be a common need.
You also need to deal with things like: Am I in a CDATA section? Easy on the whole but still a pain in the ass
@sixtyfootersdude:Just sayin, since it seems the wheels you've found aren't working for you...
Fair enough. Found a good (although not stand alone) solution.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.