Skip to content

Instantly share code, notes, and snippets.

View molnarp's full-sized avatar

Peter Molnar molnarp

  • Brandwatch
  • Copenhagen, Denmark
View GitHub Profile
function formatXml(xml) {
var formatted = '';
var reg = /(>)(<)(\/*)/g;
xml = xml.replace(reg, '$1\r\n$2$3');
var pad = 0;
jQuery.each(xml.split('\r\n'), function(index, node) {
var indent = 0;
if (node.match( /.+<\/\w[^>]*>$/ )) {
indent = 0;
} else if (node.match( /^<\/\w/ )) {