note 72182 added to ref.simplexml

From: Date: Sat, 06 Jan 2007 04:59:24 +0000
Subject: note 72182 added to ref.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-121347@lists.php.net to get a copy of this message
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); } ---- Server IP: 216.194.113.175 Probable Submitter: 64.81.243.90 ---- Manual Page -- http://www.php.net/manual/en/ref.simplexml.php Edit -- https://master.php.net/note/edit/72182 Del: integrated -- https://master.php.net/note/delete/72182/integrated Del: useless -- https://master.php.net/note/delete/72182/useless Del: bad code -- https://master.php.net/note/delete/72182/bad+code Del: spam -- https://master.php.net/note/delete/72182/spam Del: non-english -- https://master.php.net/note/delete/72182/non-english Del: in docs -- https://master.php.net/note/delete/72182/in+docs Del: other reasons-- https://master.php.net/note/delete/72182 Reject -- https://master.php.net/note/reject/72182 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#121347) next »