Re: XML Tree & $path/$pos

From: Date: Thu, 13 Mar 2003 14:30:53 +0000
Subject: Re: XML Tree & $path/$pos
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4200@lists.php.net to get a copy of this message
worked around with the old and new trees I have generated a new tree and copied to the new tree the root (modified one) from old tree cause the $tree->get() wouldn't get my modified root. can someone tell me how $path and $pos work and/or an insertChild example? thanks... ----- Original Message ----- From: "Paul Dorneanu" <spooky@rufon.org> To: <pear-general@lists.php.net> Sent: Thursday, March 13, 2003 4:08 PM Subject: Re: [PEAR] XML Tree & $path/$pos > replying to myself > I've realised that in order to delete a child of a child I must call the > child's method and not root's. > That worked. > Still haven't figured out about path/pos. I need to insert a child. So, > someone can help me get clear wit it? > > And another thing I am unclear: > --------- > require_once "XML/Tree.php"; > $tree = new XML_Tree(); > $root =& $tree->getTreeFromString($oldxml); > $paragraph =& $root->addChild("paragraph", > $_POST['newparagraph']); > $image =& $root->addChild("myimage", > "data/user_pics/spooky.jpg"); > die (dump2var($tree->get())."<hr>".dump2var($root)); > ------ > dump2var is a function of mine to get an html dump of var. > ----- > the result of $tree->get() is: > <?xml version="1.0"?> > <page> > <paragraph>rtryrtyrty</paragraph> > </page>----- > the result of $root is: > > xml_tree_node Object > ( > [attributes] => Array > ( > ) > > [children] => Array > ( > [0] => xml_tree_node Object > ( > [attributes] => Array > ( > ) > > [children] => Array > ( > ) > > [content] => rtryrtyrty > [name] => paragraph > ) > > [1] => xml_tree_node Object > ( > [attributes] => Array > ( > ) > > [children] => Array > ( > ) > > [content] => ttttttttttttttttttttttttttttttttttttt > [name] => paragraph > ) > > [2] => xml_tree_node Object > ( > [attributes] => Array > ( > ) > > [children] => Array > ( > ) > > [content] => data/user_pics/spooky.jpg > [name] => myimage > ) > > ) > > [content] => > [name] => page > )-----Why $tree->get() isn't getting the new generated tree, but instead, > the old one.Why? > ----- Original Message ----- > From: "Paul Dorneanu" <spooky@rufon.org> > To: <pear-general@lists.php.net> > Sent: Thursday, March 13, 2003 12:46 PM > Subject: [PEAR] XML Tree & $path/$pos > > > Hi. I am new to XML Trees. > I need to remove a child of a child and I can't figure out how the path > should look like. > > In my example I need to remove <paragraph>, that is a child of section > (child of root). > Now, $root->removeChild(id) works for removing "section" child. > So, how do I do it and more exactly what $path and $pos looks like? > <?xml version="1.0"?> > <page> > <section id="3"> > <paragraph>my text here</paragraph> > <myimage>spooky.jpg</myimage> > </section> > </page>Thanks > > > > -- > PEAR General Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.pear.general (#4200) next »