Hi,

Friday, July 4, 2003, 4:54:06 AM, you wrote:
MG> I'm attempting to create a generic XML writer with the DOMXML functions
MG> which takes as its input the array structure generated by gdemartiti on this
MG> function page:
MG> http://us3.php.net/manual/en/function.xml-parse-into-struct.php

MG> Actually, it's the updated version done by [EMAIL PROTECTED], here:
MG> http://www.devdump.com/phpxml.php

MG> Anyway, the trouble I'm having is when I get to a child element and need to
MG> use 'append_child' -- append_child requires that you specify the ancestor
MG> element you're appending to, but I can't seem to reference that object when
MG> I loop back into the function.  This is probably a class/object issue since
MG> I'm pretty useless with classes.

MG> If I come into the function, having passed the ancestor name as a string and
MG> having already added the ancestor as an object in the class, this doesn't
MG> work:

$child = $ancestor->>append_child($thisChild);

MG> The error is: "...Call to a member function on a non-object...".  How can I
MG> reference that ancestor object when I come back into the function?

MG> (PHP version is 4.3.2, Apache 2.0.44 on Win2k)

You have to pass references to the objects, the ones returned by
append_child. The first time you have to get the root parent and work
from there onwards.

like :
 $doc = domxml_new_doc("1.0");
 $table = $doc->create_element("table");
 $row = $doc->create_element("row");
 $col = $doc->create_element("td");

 $root = $dom->document_element();
 $t1 = $root->append_child($table);
   $r1 = $t1->append_child($row);
    $c1 = $r1->append_child($col);
    $c2 = $r1->append_child($col);
   $r2 = $t1->append_child($row);
    $c3 = $r1->append_child($col);
    $c4 = $r1->append_child($col);




-- 
regards,
Tom


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to