note 73659 modified in function.simplexml-element-asXML by danbrown
| From: | danbrown@php.net | Date: | Wed, 16 Sep 2009 15:41:09 +0000 |
| Subject: | note 73659 modified in function.simplexml-element-asXML by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160648@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.
--was--
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.
http://php.net/manual/en/function.simplexml-element-asXML.php