note 72182 deleted from ref.simplexml by didou

From: Date: Tue, 16 Jan 2007 00:57:26 +0000
Subject: note 72182 deleted from ref.simplexml by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-121777@lists.php.net to get a copy of this message
Note Submitter: steve at saturn5 dot com ---- When tidy isn't available, I use this function for pretty printing the XML generated by SimpleXMLElement::asXML(). It's probably not as efficient as tidy but it does the job when you need it. Note that there should be no whitespace at the beginning of each line between $XSL = <<< EOF and EOF; function pretty_xml($content) { $XSL = <<< EOF <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output encoding="UTF-8" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="*"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> EOF; $xsl = new DOMDocument; $xsl->loadXML($XSL); $proc = new XSLTProcessor; $proc->importStyleSheet($xsl); $xml = new DOMDocument; $xml->loadXML($content); return $proc->transformToXML($xml); }

« previous php.notes (#121777) next »