使用得是Emeditor
下面這段是這個網頁版的javascript格式化XML的代碼
<!DOCTYPE HTML PUBLIC "
<html>
<head>
<meta http
<title>Xml格式化工具</title>
<script type="text/javascript">
String
{
return this
}
function formatXml(text)
{
//去掉多余的空格
text =
{
return name +
})
//把注釋編碼
text = text
{
var ret =
//alert(ret);
return ret;
})
//調整格式
var rgx = /n(<(([^?])
var nodeStack = [];
var output = text
var isClosed = (isCloseFull
//alert([all
var prefix =
if(isBegin ==
{
prefix = getPrefix(nodeStack
}
else
{
if(isBegin !=
{
prefix = getPrefix(nodeStack
if(!isClosed)
{
nodeStack
}
}
else
{
nodeStack
prefix = getPrefix(nodeStack
}
}
var ret =
return ret;
});
var prefixSpace =
var outputText = output
//alert(outputText);
//把注釋還原並解碼
outputText = outputText
{
//alert([
if(prefix
prefix = prefix
text = unescape(text)
var ret =
//alert(ret);
return ret;
});
return outputText
}
function getPrefix(prefixIndex)
{
var span =
var output = [];
for(var i =
{
output
}
return output
}
function btnFormat_click()
{
var $ = document
$(
}
</script>
</head>
<body>
<textarea id="input" style="width:
<div style="margin:
<textarea id="output" style="width:
</body>
</html>
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20047.html