macos Mac 上的免费 XML 格式化程序(缩进)工具?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5948176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:03:04  来源:igfitidea点击:

Free XML formatter (indent) tool on Mac?

xmlmacoseditor

提问by Yang

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

需要一个可以在 Mac 上以人类可读格式格式化 xml 的工具!

采纳答案by Oct

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

我建议您安装 XMLLint,它是查看漂亮格式化的 XML(包含在 LibXML 包中)的最佳解决方案。

回答by bergonzzi

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

我将 TextWrangler(免费)与使用 xmllint 的文本过滤器一起使用。在这里下载: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:

获得后,创建一个新文件并在 .sh 下使用类似 tidy.sh 的名称保存它~/Library/Application Support/TextWrangler/Text Filters。在文件中写入以下内容并保存:

#!/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:

以上应该也适用于 BBEdit 11。对于 TextWrangler < 4.0 或 BBEdit < 11 的版本,这个脚本应该略有不同:

#!/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).

然后,您将能够从“文本”菜单 >“应用文本过滤器”>“整洁”中应用它。为了使它更容易,您可以为此绑定一个快捷方式。转到窗口 > 调色板 > 文本过滤器。你会在那里看到你的整洁过滤器。选择并点击“设置键...”并选择适合您的组合(我使用 alt+cmd+x)。

回答by Funkwarrior

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

今天刚开始用serna:http: //www.serna-xmleditor.com