Skip to content

Instantly share code, notes, and snippets.

View kurtsson's full-sized avatar

Martin Kurtsson kurtsson

View GitHub Profile
@kurtsson
kurtsson / formatXML.js
Last active August 10, 2023 13:22 — forked from sente/formatXML.js
formatXML.js but without jQuery dependency
function formatXml(xml) {
var formatted = '';
var reg = /(>)(<)(\/*)/g;
xml = xml.toString().replace(reg, '$1\r\n$2$3');
var pad = 0;
var nodes = xml.split('\r\n');
for(var n in nodes) {
var node = nodes[n];
var indent = 0;
if (node.match(/.+<\/\w[^>]*>$/)) {