identstring added to constructor and inherited to children

This commit is contained in:
Ralf Becker 2002-10-01 23:35:30 +00:00
parent 18d88685cf
commit 68f4bcc745

View File

@ -1,8 +1,7 @@
<?php
function var2xml($name, $data)
{
$doc = new xmltool();
$doc->indentstring = '';
$doc = new xmltool('root','','');
return $doc->import_var($name,$data,True,True);
}
@ -22,9 +21,10 @@
var $indentstring = "\t";
/* start the class as either a root or a node */
function xmltool ($node_type = 'root', $name='')
function xmltool ($node_type = 'root', $name='',$indentstring="\t")
{
$this->node_type = $node_type;
$this->indentstring = $indentstring;
if ($this->node_type == 'node')
{
if($name != '')
@ -155,7 +155,8 @@
function import_var($name, $value,$is_root=False,$export_xml=False)
{
$node = new xmltool('node',$name);
echo "<p>import_var: this->indentstring='$this->indentstring'</p>\n";
$node = new xmltool('node',$name,$this->indentstring);
switch (gettype($value))
{
case 'string':
@ -208,12 +209,12 @@
case 'integer':
case 'double':
case 'NULL':
$subnode = new xmltool('node', $nextkey);
$subnode = new xmltool('node', $nextkey,$this->indentstring);
$subnode->set_value($val);
$node->add_node($subnode);
break;
case 'boolean':
$subnode = new xmltool('node', $nextkey);
$subnode = new xmltool('node', $nextkey,$this->indentstring);
if($val == True)
{
$subnode->set_value('1');
@ -239,7 +240,7 @@
}
break;
case 'object':
$subnode = new xmltool('node', $nextkey);
$subnode = new xmltool('node', $nextkey,$this->indentstring);
$subnode->set_value('PHP_SERIALIZED_OBJECT&:'.serialize($val));
$node->add_node($subnode);
break;
@ -378,7 +379,7 @@
{
case 'cdata':
case 'complete':
$node = new xmltool('node',$data[$i]['tag']);
$node = new xmltool('node',$data[$i]['tag'],$this->indentstring);
if(is_array($data[$i]['attributes']) && count($data[$i]['attributes']) > 0)
{
while(list($k,$v)=each($data[$i]['attributes']))
@ -390,7 +391,7 @@
$parent_node->add_node($node);
break;
case 'open':
$node = new xmltool('node',$data[$i]['tag']);
$node = new xmltool('node',$data[$i]['tag'],$this->indentstring);
if(is_array($data[$i]['attributes']) && count($data[$i]['attributes']) > 0)
{
while(list($k,$v)=each($data[$i]['attributes']))
@ -416,7 +417,7 @@
xml_parse_into_struct($parser, $xmldata, $vals, $index);
xml_parser_free($parser);
unset($index);
$node = new xmltool('node',$vals[0]['tag']);
$node = new xmltool('node',$vals[0]['tag'],$this->indentstring);
if(isset($vals[0]['attributes']))
{
while(list($key,$value) = each($vals[0]['attributes']))