[phpXML] Re: [phpXML] add_node problem
Brought to you by:
bs_php,
nigelswinson
From: <nig...@us...> - 2001-10-08 18:10:21
|
Try $nn =3D $xml->add_node("/root[1]", "node"). "root" is not a "full" XPa= th address. "root[1]" is. The only function that would allow you to enter= "root" is evaluate(), and it returns you an array of paths. So you could do: $aArray =3D $xml->evaluate("/root"); $NewNodeFullPath =3D $add_xml->node($aArray[0], "node"); Nigel =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D For the most recent version of phpxml, V1.N.X, and an archive of this list = visit: http://www.sourceforge.net/projects/phpxmldb ----- Original Message -----=20 From: se...@ww...=20 To: us...@li...=20 Sent: Thursday, September 06, 2001 3:31 AM Subject: [phpXML] add_node problem Hello all, =20=20=20 I'm trying to use PHPxml for working with XML document. Everyting works f= ine except adding the new nodes. Frankly speaking, method add_node doesn't = work. =20=20=20 It returns path for the new node, but when I'm trying to get the results = and show them or save it to file - I see NO new node that had been added. =20=20=20 Please take a look at my code: ---------------------------------------------------------------------------= --- <? // Include the <phpXML/> class. include("lib/xml.php"); =20=20=20 // Create an XML object for the XML file. $xml =3D new XML("some.xml"); =20=20=20 $nn =3D $xml->add_node("/", "node"); $fp =3D fopen("some2.xml","w+"); // characters translation $trans =3D get_html_translation_table(HTML_ENTITIES); $trans =3D array_flip($trans); $xs =3D strtr($xml->get_file(), $trans); // write fputs($fp, $xs); fclose($fp); =20=20=20 ?> ---------------------------------------------------------------------------= --- file SOME.XML: =20=20=20 <?xml version=3D"1.0" encoding=3D"UTF-8"?> <root/> ---------------------------------------------------------------------------= --- get_file methid returns original XML - simply <root/>. Note that I tried = different variations of path parameter string in add_node method. (ie "root= /", "/root", ".", "/", "/root/"... and so on) =20=20=20 When I 'm trying to get the path for the new created node I get a result = - root/node[1]. But there no new node in the xml. =20=20=20 Please, can you explain me why this happens? Or maybe I'm using add_node = not very correctly? =20=20=20 Serge. -- This message has been sent through the <phpXML/> user discussion list. To u= nsubscribe, please visit https://sslsites.de/mailinglisten/user/user@lists.= phpxml.org/ |