Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Free XML formatter (indent) tool on Mac? [closed]

Tags:

editor

macos

xml

Need a tool that can format the xml in human readable format on Mac!

like image 309
Yang Avatar asked May 10 '11 09:05

Yang


1 Answers

I use TextWrangler (free) together with a text filter which uses xmllint. Download it here: http://www.barebones.com/products/textwrangler/download.html

After you have it, create a new file and save it with a name like tidy.sh under ~/Library/Application Support/TextWrangler/Text Filters. Write the following in the file and save it:

#!/bin/sh
XMLLINT_INDENT=$'\t' xmllint --format --encode utf-8 - 

The above should also work for BBEdit 11. For versions of TextWrangler < 4.0 or BBEdit < 11, this script should be slightly different:

#!/bin/sh
xmllint "$*" | XMLLINT_INDENT=$'\t' xmllint --format --encode utf-8 -

Then you'll be able to apply this from the Text menu > Apply Text Filter > tidy To make it even easier, you can bind a shortcut to this. Go to Window > Palettes > Text Filters. You will see your tidy filter there. Select and hit "Set Key..." and choose a combination that suits you (I use alt+cmd+x).

like image 158
bergonzzi Avatar answered Oct 25 '22 23:10

bergonzzi