Tuesday, April 1, 2014

XML Formatting in Edit Plus

I was thinking of writing a macro to help me format XML in Edit Plus. Fortunately, someone else already came up with a better solution 5 years ago.

In case this link ever dies, here's the code he used:
var stdin  = WScript.StdIn; var stdout = WScript.StdOut; var xml = WScript.createObject("MSXML2.DomDocument"); xml.loadXML(stdin.ReadAll().replace(/\t/g, '').replace(/\r|\n/g, '').replace(/\>\</g, '>\n<')); stdout.Write(xml.xml.substr(0, xml.xml.length-2));
This is why I love the internet.

No comments:

Post a Comment