function import_var($name, $value, $is_root = False, $export_xml = False)
 {
     echo "<p>import_var: this->indentstring='{$this->indentstring}'</p>\n";
     $node = new xmltool('node', $name, $this->indentstring);
     switch (gettype($value)) {
         case 'string':
         case 'integer':
         case 'double':
         case 'NULL':
             $node->set_value($value);
             break;
         case 'boolean':
             if ($value == True) {
                 $node->set_value('1');
             } else {
                 $node->set_value('0');
             }
             break;
         case 'array':
             $new_index = False;
             while (list($idxkey, $idxval) = each($value)) {
                 if (is_array($idxval)) {
                     while (list($k, $i) = each($idxval)) {
                         if (is_int($k)) {
                             $new_index = True;
                         }
                     }
                 }
             }
             reset($value);
             while (list($key, $val) = each($value)) {
                 if ($new_index) {
                     $keyname = $name;
                     $nextkey = $key;
                 } else {
                     $keyname = $key;
                     $nextkey = $key;
                 }
                 switch (gettype($val)) {
                     case 'string':
                     case 'integer':
                     case 'double':
                     case 'NULL':
                         $subnode = new xmltool('node', $nextkey, $this->indentstring);
                         $subnode->set_value($val);
                         $node->add_node($subnode);
                         break;
                     case 'boolean':
                         $subnode = new xmltool('node', $nextkey, $this->indentstring);
                         if ($val == True) {
                             $subnode->set_value('1');
                         } else {
                             $subnode->set_value('0');
                         }
                         $node->add_node($subnode);
                         break;
                     case 'array':
                         if ($new_index) {
                             while (list($subkey, $subval) = each($val)) {
                                 $node->add_node($this->import_var($nextkey, $subval));
                             }
                         } else {
                             $subnode = $this->import_var($nextkey, $val);
                             $node->add_node($subnode);
                         }
                         break;
                     case 'object':
                         $subnode = new xmltool('node', $nextkey, $this->indentstring);
                         $subnode->set_value('PHP_SERIALIZED_OBJECT&:' . serialize($val));
                         $node->add_node($subnode);
                         break;
                     case 'resource':
                         echo 'Halt: Cannot package PHP resource pointers into XML<br>';
                         exit;
                     default:
                         echo 'Halt: Invalid or unknown data type<br>';
                         exit;
                 }
             }
             break;
         case 'object':
             $node->set_value('PHP_SERIALIZED_OBJECT&:' . serialize($value));
             break;
         case 'resource':
             echo 'Halt: Cannot package PHP resource pointers into XML<br>';
             exit;
         default:
             echo 'Halt: Invalid or unknown data type<br>';
             exit;
     }
     if ($is_root) {
         $this->add_node($node);
         if ($export_xml) {
             $xml = $this->export_xml();
             return $xml;
         } else {
             return True;
         }
     } else {
         $this->add_node($node);
         return $node;
     }
 }
 public function import_var($name, $value, $is_root = false, $export_xml = false)
 {
     $node = new xmltool('node', $name, $this->indentstring);
     switch (gettype($value)) {
         case 'string':
         case 'integer':
         case 'double':
         case 'NULL':
             $node->set_value($value);
             break;
         case 'boolean':
             if ($value == true) {
                 $node->set_value('1');
             } else {
                 $node->set_value('0');
             }
             break;
         case 'array':
             $new_index = false;
             foreach ($value as $val) {
                 if (is_array($val) && count($val)) {
                     list($first_key) = array_keys($val);
                     if (is_int($first_key)) {
                         $new_index = true;
                         break;
                     }
                 }
             }
             foreach ($value as $key => $val) {
                 if ($new_index) {
                     $keyname = $name;
                     $nextkey = $key;
                 } else {
                     $keyname = $key;
                     $nextkey = $key;
                 }
                 switch (strtolower(gettype($val))) {
                     case 'string':
                     case 'integer':
                     case 'double':
                     case 'null':
                         $subnode = new xmltool('node', $nextkey, $this->indentstring);
                         $subnode->set_value($val);
                         $node->add_node($subnode);
                         break;
                     case 'boolean':
                         $subnode = new xmltool('node', $nextkey, $this->indentstring);
                         $subnode->set_value((int) $val);
                         $node->add_node($subnode);
                         break;
                     case 'array':
                         list($first_key) = each($val);
                         if ($new_index && is_int($first_key)) {
                             foreach ($val as $subval) {
                                 $node->add_node($this->import_var($nextkey, $subval));
                             }
                         } else {
                             $subnode = $this->import_var($nextkey, $val);
                             $node->add_node($subnode);
                         }
                         break;
                     case 'object':
                         $subnode = new xmltool('node', $nextkey, $this->indentstring);
                         $subnode->set_value((string) $val);
                         $node->add_node($subnode);
                         break;
                     case 'resource':
                         trigger_error('Cannot package PHP resource pointers into XML', E_USER_ERROR);
                     default:
                         trigger_error('Invalid or unknown data type', E_USER_ERROR);
                 }
             }
             break;
         case 'object':
             $subnode->set_value((string) $value);
             break;
         case 'resource':
             trigger_error('Cannot package PHP resource pointers into XML', E_USER_ERROR);
         default:
             trigger_error('Invalid or unknown data type', E_USER_ERROR);
     }
     if ($is_root) {
         $this->add_node($node);
         if ($export_xml) {
             $xml = $this->export_xml();
             return $xml;
         }
         return true;
     }
     $this->add_node($node);
     return $node;
 }