I need to integrate the code that is in the answer to this thread.
When I do it as a library I get error "construct", I do not have much knowledge about it, I hope you can help me.
I need to integrate the code that is in the answer to this thread.
When I do it as a library I get error "construct", I do not have much knowledge about it, I hope you can help me.
 
    
     
    
    From this class:
class ExSimpleXMLElement extends SimpleXMLElement 
{ 
    public function _construct($xml){
        parent::_construct($xml);
    }
    /** 
     * 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); 
            } 
         } 
     } 
} 
You would transform it like this:
<?php
class ExSimpleXMLElement
{ 
    private $sxe;
    public function loadXml($xml){
        $this->sxe = new SimpleXMLElement($xml);
    }
    /** 
    * Add SimpleXMLElement code into a SimpleXMLElement 
    * @param SimpleXMLElement $append 
    */ 
    public function appendXML($append) 
    {
        if ($append) { 
            if (strlen(trim((string) $append))==0) { 
                $xml = $this->sxe->addChild($append->getName()); 
                foreach($append->children() as $child) { 
                    $xml->appendXML($child); 
                } 
            } else { 
                $xml = $this->sxe->addChild($append->getName(), (string) $append); 
            }     
            foreach($append->attributes() as $n => $v) { 
                $xml->addAttribute($n, $v); 
            } 
        } 
    } 
}
And use it like this:
$this->load->library('ExSimpleXMLElement');
$this->exsimplexmlelement->loadXML($xml);
