note 73659 added to function.simplexml-element-asXML
| From: | ShinnyLeather at osu1 dot php dot net | Date: | Tue, 06 Mar 2007 05:39:43 +0000 |
| Subject: | note 73659 added to function.simplexml-element-asXML | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124134@lists.php.net to get a copy of this message | ||
Awww snap. If you are to do something like this:
<?php
// ... You have already read an xml file into a SimpleXMLElement stored in variable $poop
$poop = $simpEle->addChild("poop");
$poop->addAttribute("from", "Myself");
$poop->addChild("smell", "stinky");
file_put_contents("xml.xml", $poop->asXML());
?>
It will add all of the new xml on one line
<poop from="Myself"><smell>stinky</smell></poop>
So when you look at what was originally a nicely tabbed out xml file, it looks like doof. I
understand why this happens, so let me just say that it would be awesome if someone wrote and shared
function that takes the asXML() string, parses it, and returns a nicely tabbed out version. As a lot
of the XML files I work with are smaller than large, the benefit of having a file readable to the
human eye far outweights the benefit of having a smaller filesize.
----
Server IP: 64.71.164.2
Probable Submitter: 209.223.157.241
----
Manual Page -- http://www.php.net/manual/en/function.simplexml-element-asXML.php
Edit -- https://master.php.net/note/edit/73659
Del: integrated -- https://master.php.net/note/delete/73659/integrated
Del: useless -- https://master.php.net/note/delete/73659/useless
Del: bad code -- https://master.php.net/note/delete/73659/bad+code
Del: spam -- https://master.php.net/note/delete/73659/spam
Del: non-english -- https://master.php.net/note/delete/73659/non-english
Del: in docs -- https://master.php.net/note/delete/73659/in+docs
Del: other reasons-- https://master.php.net/note/delete/73659
Reject -- https://master.php.net/note/reject/73659
Search -- https://master.php.net/manage/user-notes.php