Formatting XML and JSON using Sublime Text

Formatting XML and JSON using Sublime Text

Last week I was trying to make some changes to my WCF service and had to deal with some XML data. The problem was the XML was not nicely formatted and I had to highlight couple of missing pieces of information. Normally I would use Notepad++ but I though let's try doing it in "Sublime Text".

If you are new to this editor you can read my this post which describes the basic steps to get started with Sublime Text. As a web developer we often have to deal with non formatted XML and JSON data. Sublime Text has a plugin Indext XML that you can use to format XML and JSON data. The plug-in is available in both ST2 & ST3.
插件官网地址:

https://github.com/alek-sys/sublimetext_indentxml

Installing Plug-in

Open the editor and hit Ctrl+Shift+P to open Command Palette.

Type"Install Package" and hit Enter. Type Indent XML.

Select the highlighted plug-in and click Enter. You should see the message that saying the plug-in has been installed successfully.

Restart the editor. At least I had to.

Formatting XML

Copy the non formatted XML

Hit Ctrl + K + F.

You can also do it from the Menu option.

Formatting JSON

Hit Ctrl + K + F.

You can also do it from the Menu option.

 

遇到的问题是,下面的xml报文不能格式化,原因是头文件问题,将其去掉即可

 

 

 

 

posted @ 2017-02-21 14:52  zhaozhenqiang  阅读(386)  评论(0编辑  收藏  举报