protected $name = "";
 protected $value = "";
 protected $attributes = array();
 protected $children = array();
 public function __construct($data = null)
 {
     if (is_null($data)) {
         $name = preg_replace('#^(certissim-)?(.*)$#', '$2', CertissimTools::normalizeName(get_class($this)));
         $this->setName($name);
     }
     //if $data is a valid string
     if (is_string($data)) {
         //drops spaces at the beginning of the string
         $data = preg_replace('#^[ \\r\\n]*#', '', $data);
         //checks the XML validity
         if (!CertissimTools::isXMLstring($data)) {
             $msg = "La chaine \"{$data}\" n'est pas valide";
             CertissimLogger::insertLog(get_class($this) . ' - __construct()', $msg);
             throw new Exception($msg);
         }
         //convert string into SimpleXMLElement
         $data = new SimpleXMLElement($data);
     }
     //if $data is SimpleXMLElement
     if (CertissimTools::isSimpleXMLElement($data)) {
         $string = (string) $data;
         $this->name = $data->getName();
         $this->value = $string;
         foreach ($data->attributes() as $attname => $attvalue) {
             $this->attributes[$attname] = $attvalue;
         }
         foreach ($data->children() as $simplexmlelementchild) {
             $child = new CertissimXMLElement($simplexmlelementchild);
 public function __construct($data = null, $debug = false)
 {
     if (is_null($data)) {
         $name = preg_replace('#^(sceau-)?(.*)$#', '$2', CertissimTools::normalizeName(get_class($this)));
         $this->setName($name);
     }
     if (is_string($data)) {
         $data = preg_replace('#^[ \\r\\n' . chr(13) . chr(10) . ']*#', '', $data);
         if (!SceauTools::isXMLstring($data)) {
             $msg = "La chaine \"{$data}\" n'est pas valide";
             SceauTools::insertLog(__METHOD__ . ' : ' . __LINE__, $msg);
             throw new Exception($msg);
         }
         $data = new SimpleXMLElement($data);
     }
     if (is_object($data) && get_class($data) == 'SimpleXMLElement') {
         $string = (string) $data;
         $this->name = $data->getName();
         $this->value = trim($string);
         foreach ($data->attributes() as $attname => $attvalue) {
             $this->attributes[$attname] = $attvalue;
         }
         foreach ($data->children() as $simplexmlelementchild) {
             $child = new SceauXMLElement($simplexmlelementchild);
             $this->addChild($child);
         }
     }
 }