1.js部分
// 格式化xml 高亮显示
//返回已经处理的xml字符,配合CSS产生高亮
function formatXml (content) {
debugger;
let xml_doc = null;
const formatContent = content.replace(/[\n\r]/g, "");
try {
xml_doc = (new DOMParser()).parseFromString(formatContent, 'text/xml');
} catch (e) {
return false;
}
function build_xml(list, element, level) {
let t = [];
/*level 节点层级。方便前面添加多少个空格缩进*/
for (let i = 0; i < level; i++) {
t.push(' ');
}
t = t.join("");
list.push(t + '<<span class="code-key">' + element.nodeName + '</span>>\n');
for (let i = 0; i < element.childNodes.length; i++) {
const childLevel = level + 1;
let childItem = element.childNodes[i];
let nodeName = childItem