note 104458 added to simplexmlelement.addchild

From: Date: Thu, 16 Jun 2011 09:52:34 +0000
Subject: note 104458 added to simplexmlelement.addchild
Groups: php.notes 
Request: Send a blank email to php-notes+get-180598@lists.php.net to get a copy of this message
Here is a class with more functions for SimpleXMLElement : /** * * Extension for SimpleXMLElement * @author Alexandre FERAUD * */ class ExSimpleXMLElement extends SimpleXMLElement { /** * Add CDATA text in a node * @param string $cdata_text The CDATA value to add */ private function addCData($cdata_text) { $node= dom_import_simplexml($this); $no = $node->ownerDocument; $node->appendChild($no->createCDATASection($cdata_text)); } /** * Create a child with CDATA value * @param string $name The name of the child element to add. * @param string $cdata_text The CDATA value of the child element. */ public function addChildCData($name,$cdata_text) { $child = $this->addChild($name); $child->addCData($cdata_text); } /** * Add SimpleXMLElement code into a SimpleXMLElement * @param SimpleXMLElement $append */ public function appendXML($append) { if ($append) { if (strlen(trim((string) $append))==0) { $xml = $this->addChild($append->getName()); foreach($append->children() as $child) { $xml->appendXML($child); } } else { $xml = $this->addChild($append->getName(), (string) $append); } foreach($append->attributes() as $n => $v) { $xml->addAttribute($n, $v); } } } } ---- Server IP: 69.147.83.197 Probable Submitter: 82.127.5.151 ---- Manual Page -- http://www.php.net/manual/en/simplexmlelement.addchild.php Edit -- https://master.php.net/note/edit/104458 Del: integrated -- https://master.php.net/note/delete/104458/integrated Del: useless -- https://master.php.net/note/delete/104458/useless Del: bad code -- https://master.php.net/note/delete/104458/bad+code Del: spam -- https://master.php.net/note/delete/104458/spam Del: non-english -- https://master.php.net/note/delete/104458/non-english Del: in docs -- https://master.php.net/note/delete/104458/in+docs Del: other reasons-- https://master.php.net/note/delete/104458 Reject -- https://master.php.net/note/reject/104458 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#180598) next »