开发者

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

开发者 https://www.devze.com 2023-03-05 00:09 出处:网络
开发者_C百科 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solic
开发者_C百科 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

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


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).


I suggest you install XMLLint which the best solution to view pretty formatted XML (included in LibXML package.


Just started today to use Serna: http://www.serna-xmleditor.com

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号