Formatting XML

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
marc_scheuner
Posts: 10
Joined: Wed Jan 28, 2004 1:32 pm
Location: Berne Switzerland

Formatting XML

Post by marc_scheuner »

Folks,

is there an easy way in TextPad to nicely format XML? I'm getting back huge long single lines of XML, but I'd like to have it formatted like:

Code: Select all

<Root>
     <Level1>
           <Level2>
                  <Data attrib="something" value="else" />
           </Level2>
     </Level1>
</Root>
I can do this externally using command-line tools, but it would be great to have it INSIDE TextPad.

Any ideas?

Thanks
Marc
Last edited by marc_scheuner on Fri Jun 23, 2006 5:09 pm, edited 1 time in total.
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

Perfect solution? Nope but you could do a search and replace for ><, or whatever the input string looks like, and replace with >\n< to at least get it broken out into one tag per line.
I choose to fight with a sack of angry cats.
marc_scheuner
Posts: 10
Joined: Wed Jan 28, 2004 1:32 pm
Location: Berne Switzerland

Post by marc_scheuner »

Perfect solution? Nope but you could do a search and replace for ><, or whatever the input string looks like, and replace with >\n< to at least get it broken out into one tag per line.
Yeah, that's basically what I'm doing now, but if you have a 200+ line document with hundreds of nodes and up to 10-12 levels deep, formatting that by hand - even if every tag is on a line of its own - is just a royal pain....

Thanks anyway!
Marc
Garth Fielding II
Posts: 1
Joined: Fri Jun 23, 2006 8:21 pm

Post by Garth Fielding II »

This is the best that I have found to do what you are asking. Download the program "Tidy" from the following URL: http://dev.int64.org/tidy.html

Then, go to Configure | Preferences | Tools | Add - Program. Specify the location where you saved Tidy.exe (e.g. C:\Program Files\Developer Tools\Tidy\tidy.exe)

Change Parameters to the following:
-xml -i $File

Make sure that "Capture Output" is checked.

Then, when you run this, it will output to the "Command Results" window - which you can then copy/paste back into the original document.
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

Oh yeah, use Tidy by all means. I thought you meant is there a solution via a search and replace thing.
I choose to fight with a sack of angry cats.
Post Reply