How to format XML code in Ace Editor?

柔情痞子 提交于 2019-12-14 01:32:08

问题


I am using ACE Editor to display xml content on my web page. I want to format the xml code in Editor.

Can Any one tell me how to do this ?


回答1:


There are numerous modes included in the package and the Wiki at github will tell you how to implement it. Something like this:

var Mode = require('ace/mode/xml').Mode;
editor.getSession().setMode(new Mode());



回答2:


XML Code formatting is not specified in Ace itself, as it's just an editor. Use any of the answers in this question to prettify the code.

var code = ace.getSession().getValue();
// prettify
ace.getSession().setValue(code);


来源:https://stackoverflow.com/questions/10753543/how-to-format-xml-code-in-ace-editor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!