Eric Bergman-Terrell's Blog

Node.js Programming Tip: How to Pretty-Print XML
September 14, 2015

This website's XML Pretty-Print utility uses the following code to convert JSON text into ready-to-read XML. Obviously, pretty-data is doing all the work. The second argument to the xml function specifies whether or not to retain XML comments.

var pd = require('pretty-data');

exports.prettyPrint = function(source) {
    return pd.pd.xml(source, true);
};
Pretty Print XML

I am pretty and well-formed!

Keywords: Node.js, node, Express, JavaScript, XML, pretty print, formatting, pretty-data, comments

Reader Comments

Comment on this Blog Post

Recent Posts

TitleDate
Java Programming Tip: SWT Photo Frame ProgramOctober 31, 2016
Vault 3 (Desktop) Version 1.63 ReleasedSeptember 9, 2016
"Compliance with Court Orders Act of 2016"April 9, 2016
Disable "Visual Voicemail" on Android / T-MobileJanuary 17, 2016
IPv6 HumorDecember 10, 2015
Java Programming Tip: Specify the JVM time zoneDecember 7, 2015
Node.js / Express Programming Tip: Detect and Fix Memory LeaksOctober 27, 2015