views:

3819

answers:

7

I know there are many: Notepad2, Notepad++, even UltraEdit... But I'm looking for a special feature. I want the editor to format my XML files for human understanding. When I open an XML file saved by my application all the XML is in one line, making it impossible for easy reading.

I know MS Visual Studio does it (Crtl+E, D), anyone else?

A: 

Why not just write a little program that will read in the xml file and then write it out, as the XDocument in XLINQ will do some nice formatting for you, as an option.

Just make it so it can process several files, perhaps looking for all .xml files in a specified directory.

James Black
+2  A: 

You can get a plugin for Notepad++ that does this- XML tools. I use it all the time. Once you install it you get a pretty print option.

RichardOD
I have the Notepad++ but did not know about the XML tools, thanks
sebastian
+3  A: 

If you just want to read the XML, and have no need to edit it, you could use a web browser. Both Internet Explorer and Firefox can display XML in a nicely formatted way.

Tom
A: 

FirstObject XML Editor seems to be the tool of choice, according to the stackoverflow question pointed to by bgy (in the comments).

http://www.firstobject.com/dn_editor.htm

Nosredna
A: 

I don't think you necessarily need an editor to do this.

I use XMLStarlet to manipulate XML (including reformatting). It's a command-line set of tools to query/format/validate/search XML and well-worth getting hold of.

Brian Agnew
+18  A: 

Notepad++'s TextFX and XML Tools plug-ins can do this and much more. TextFX is included in Notepad++ installation; XML Tools can be downloaded from here. The menu commands to format XML are:

TextFX | TextFX HTML Tidy | Tidy: Reindent XML

Plugins | XML Tools | Pretty print (XML only - with line breaks)

Helen
Brilliant! Thanks!
Lee Oades
+1 saved my time, thanks :).
Gollum
A: 

XML Notepad doesn't reformat (I don't think) but gives a more structured display of the data in an xml file: http://www.microsoft.com/DownLoads/details.aspx?FamilyID=72d6aa49-787d-4118-ba5f-4f30fe913628&displaylang=en

Karim
It DOES if you make any change and then save the file.
Albert Gareev