/**
  * The construct.  Pass the array in here, then call get_xml_string() to see the results.
  */
 public function __construct($xmlArray, $preserveCase = false)
 {
     if (is_array($xmlArray) && count($xmlArray)) {
         //all looks good.  Give 'em the go ahead.
         $this->goAhead = TRUE;
         $this->xmlArray = $xmlArray;
         if (is_bool($preserveCase)) {
             $this->preserveCase = $preserveCase;
         }
         //check to make sure there's only ONE root element.
         if (count($xmlArray) != 1) {
             throw new exception(__METHOD__ . ": one (and only one) root element allowed");
         }
         $keys = array_keys($xmlArray);
         $this->rootElement = $keys[0];
         if (!$this->preserveCase) {
             $this->rootElement = strtoupper($this->rootElement);
         }
         //create an arrayToPath{} object.
         parent::__construct($xmlArray);
     } else {
         throw new exception(__METHOD__ . ": FATAL: no array passed::: " . $this->gfObj->debug_var_dump($xmlArray));
     }
 }
Esempio n. 2
0
 public function fix_path($path)
 {
     return parent::fix_path($path);
 }
 /**
  * CONSTRUCTOR: Read in XML on object creation, via raw data (string), stream, filename, or URL.
  */
 function __construct($data_source, $preserveCase = false)
 {
     parent::__construct(array());
     if ($data_source === 'unit_test') {
         //this is only a test... don't do anything.
         $this->isTest = TRUE;
     } else {
         $this->get_version();
         if (is_bool($preserveCase)) {
             $this->preserveCase = $preserveCase;
         }
         $this->data = '';
         if (preg_match('/^</', $data_source)) {
             $this->data = $data_source;
             $this->get_tree();
         } else {
             //something went horribly wrong.
             throw new exception(__METHOD__ . ": FATAL: invald data::: " . htmlentities($data_source));
         }
     }
 }
 /**
  * The constructor.
  */
 public function __construct($rootElement = "main", array $xmlns = NULL, $preserveCase = false)
 {
     //check to ensure there's a real element.
     if (!strlen($rootElement)) {
         //Give it a default root element.
         $rootElement = "main";
     }
     if (is_bool($preserveCase)) {
         $this->preserveCase = $preserveCase;
     }
     if (!$this->preserveCase) {
         $this->rootElement = strtoupper($this->rootElement);
     }
     //set the root element
     if (!$this->preserveCase) {
         $rootElement = strtoupper($rootElement);
     }
     $this->rootElement = $rootElement;
     //create our internal data structure using arrayToPath{}.
     parent::__construct();
 }