Eden Ridgway's Blog

.Net and Web Development Information

  Home :: Contact :: Syndication  :: Login
  105 Posts :: 1 Stories :: 78 Comments :: 3 Trackbacks

Search

Article Categories

Archives

Post Categories

Development

General

Oleg Tkachenko posted an article on his blog about pretty printing XML documents using MSXML's SAX implementation. I've taken his example and reproduced it here with some minor modifications more for my own record keeping more than anything else:

function PrettyPrintXml(xml)
{
var reader = new ActiveXObject("Msxml2.SAXXMLReader.4.0");
var
writer = new ActiveXObject("Msxml2.MXXMLWriter.4.0");
writer.indent = true;
writer.standalone = true;
reader.contentHandler = writer;
reader.putProperty("http://xml.org/sax/properties/lexical-handler", writer);
reader.parse(xml);
return
writer.output;
}
And here is a demo: XmlPrettyPrint.htm (1.04 KB)
posted on Wednesday, November 30, 2005 3:31 AM
Comments have been closed on this topic.