Thread: RemoveChild Problem
Brought to you by:
bs_php,
nigelswinson
From: Jan C. <ja...@ca...> - 2001-11-30 23:26:41
|
Hi all, I am really fighting with this - it only removes "stand alone" childs and not multiple child-nodes of a node: The XML (List of birthdays per month) - (short version): <DATA> <MON07> <geburtstag> <datum>1007124449</datum> <name>asdasd</name> <tag>9</tag> </geburtstag> </MON07> <MON09> <geburtstag> <datum>1007124458</datum> <name>Jan</name> <tag>8</tag> </geburtstag> </MON09> <MON10> <geburtstag> <datum>1007124443</datum> <name>hgvghv</name> <tag>9</tag> </geburtstag> <geburtstag> <datum>1007124467</datum> <name>adsd</name> <tag>9</tag> </geburtstag> </MON10> </DATA> Now I like to delete all "geburtstag" entries which are selected by checkboxes - the value "datum" is posted by "HTTP_POST_VARS" of the checkboxes and used to indentify the individual entries: //Start as usual: $xpath_del = new XPATH($xmlfile); $path = $xpath_del->evaluate("/*/*/geburtstag"); foreach( $path as $value ) { //Get the "datum" node value in the xml $date = $xpath_del->getData($value."/datum[1]"); //Compare the "datum" with the values in the HTTP_POST_VARS array if (array_search ($date,$HTTP_POST_VARS)!="") { //Ok - this "value" node has too be deleted: echo "Now comes: ".$value."<hr>"; $xpath_del->removeChild($value); echo "Deleted<hr>"; } } I get this output result: __________________________________________________________ Now comes: /DATA[1]/MON07[1]/geburtstag[1] ---------------------------------------------------------------------------- ---- Deleted ---------------------------------------------------------------------------- ---- Now comes: /DATA[1]/MON09[1]/geburtstag[1] ---------------------------------------------------------------------------- ---- Deleted ---------------------------------------------------------------------------- ---- Now comes: /DATA[1]/MON10[1]/geburtstag[1] ---------------------------------------------------------------------------- ---- Warning: Undefined index: /DATA[1]/MON10[1]/geburtstag[1]/datum in E:\imeso\web\portal\data\xpath.class.php on line 1222 Warning: Undefined index: /DATA[1]/MON10[1]/geburtstag[1]/name in E:\imeso\web\portal\data\xpath.class.php on line 1222 Warning: Undefined index: /DATA[1]/MON10[1]/geburtstag[1]/tag in E:\imeso\web\portal\data\xpath.class.php on line 1222 Deleted ---------------------------------------------------------------------------- ---- Now comes: /DATA[1]/MON10[1]/geburtstag[2] ---------------------------------------------------------------------------- ---- Warning: Undefined index: geburtstag[2] in E:\imeso\web\portal\data\xpath.class.php on line 1098 Deleted ---------------------------------------------------------------------------- ---- Now comes: /DATA[1]/MON11[1]/geburtstag[1] ---------------------------------------------------------------------------- ---- Warning: Undefined index: /DATA[1]/MON11[1]/geburtstag[1]/datum in E:\imeso\web\portal\data\xpath.class.php on line 1222 Warning: Undefined index: /DATA[1]/MON11[1]/geburtstag[1]/name in E:\imeso\web\portal\data\xpath.class.php on line 1222 __________________________________________________________ and so on ..... Can anyone help me with this??? Thanks a lot!!! Cheers Jan |
From: Nigel S. <nig...@us...> - 2001-12-11 22:49:34
|
If you have: <DATA> <MON10> <geburtstag> <datum>1007124443</datum> <name>hgvghv</name> <tag>9</tag> </geburtstag> <geburtstag> <datum>1007124467</datum> <name>adsd</name> <tag>9</tag> </geburtstag> </MON10> </DATA> And you search for: $path = $xpath_del->evaluate("/*/*/geburtstag"); Then you get: /DATA[1]/MON10[1]/geburtstag[1] /DATA[1]/MON10[1]/geburtstag[2] Now if you delete /DATA[1]/MON10[1]/geburtstag[1], then your XML becomes: <DATA> <MON10> <geburtstag> <datum>1007124467</datum> <name>adsd</name> <tag>9</tag> </geburtstag> </MON10> </DATA> So when you now try to delete /DATA[1]/MON10[1]/geburtstag[2] it doesn't exist does it? As there is only one geburtstag[] child node of MON10. Which is why you get: > Warning: Undefined index: geburtstag[2] in > E:\imeso\web\portal\data\xpath.class.php on line 1098 There are other errors in your sample output, but as your sample output does not completely match the XML that you have mailed, (ie what is MON11??) I can't really help you with the others. Nigel =========================== For the most recent version of Php.XPath, and an archive of this list visit: http://www.sourceforge.net/projects/phpxpath |
From: J. C. <jan...@im...> - 2001-12-18 08:33:38
|
Hi, Thanks for the answer - the explanation was exactly as I already thought, but even when I tried to re-run evaluate() after each removeChild() or even with using reset() it did not help - maybe I did it wrong, but shouldn't that be the correct solution??? Any advice for a nice working script to solve this? Finally I decided to export the file after each removeChild() and read it in again - that is quite slow of cause but works at least. Don't worry about the other errors (side effects of the same problem I think - MON11 is quite similar to MON10). Cheers Jan > -----Ursprüngliche Nachricht----- > Von: php...@li... > [mailto:php...@li...]Im Auftrag von Nigel > Swinson > Gesendet: Dienstag, 11. Dezember 2001 23:48 > An: php...@li... > Betreff: Re: RemoveChild Problem > > > If you have: > > <DATA> > <MON10> > <geburtstag> > <datum>1007124443</datum> > <name>hgvghv</name> > <tag>9</tag> > </geburtstag> > <geburtstag> > <datum>1007124467</datum> > <name>adsd</name> > <tag>9</tag> > </geburtstag> > </MON10> > </DATA> > > And you search for: > > $path = $xpath_del->evaluate("/*/*/geburtstag"); > > Then you get: > > /DATA[1]/MON10[1]/geburtstag[1] > /DATA[1]/MON10[1]/geburtstag[2] > > Now if you delete /DATA[1]/MON10[1]/geburtstag[1], then your XML becomes: > > <DATA> > <MON10> > <geburtstag> > <datum>1007124467</datum> > <name>adsd</name> > <tag>9</tag> > </geburtstag> > </MON10> > </DATA> > > So when you now try to delete /DATA[1]/MON10[1]/geburtstag[2] it doesn't > exist does it? As there is only one geburtstag[] child node of MON10. > Which is why you get: > > > Warning: Undefined index: geburtstag[2] in > > E:\imeso\web\portal\data\xpath.class.php on line 1098 > > There are other errors in your sample output, but as your sample > output does > not completely match the XML that you have mailed, (ie what is MON11??) I > can't really help you with the others. > > Nigel > > =========================== > For the most recent version of Php.XPath, and an archive of this > list visit: > http://www.sourceforge.net/projects/phpxpath > > > _______________________________________________ > Phpxpath-users mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phpxpath-users |
From: Nigel S. <nig...@us...> - 2001-12-20 01:29:30
|
> Thanks for the answer - the explanation was exactly as I already thought, > but > even when I tried to re-run evaluate() after each removeChild() or even > with using reset() it did not help - maybe I did it wrong, but shouldn't > that be > the correct solution??? Any advice for a nice working script to solve this? Try deleting the nodes in the reverse order to which they come back from evalute. ie delete node 2 then 1, not 1 then 2. This means the nodes DO exist. Yeah there will be a more elegant way to do this in the future. :o) Nigel |
From: J. C. <jan...@im...> - 2002-01-02 16:52:25
|
I installed the new Version 4.1.0 of PHP (well the newest is 4.1.1 of course) and now I am getting some warnings regarding the XPath Class (no warnings with Version 4.0.6!): ______________ If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in E:\imeso\web\Administration\data\xpath.class.php on line 2296 PHP Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of call_user_method(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in E:\imeso\web\Administration\data\xpath.class.php on line 2306 PHP Warning: The call_user_method() function is deprecated, use the call_user_func variety with the array(&$obj, "method") syntax instead in E:\imeso\web\Administration\data\xpath.class.php on line 2216 PHP Warning: The call_user_method() function is deprecated, use the call_user_func variety with the array(&$obj, "method") syntax instead in E:\imeso\web\Administration\data\xpath.class.php on line 2216 PHP Warning: The call_user_method() function is deprecated, use the call_user_func variety with the array(&$obj, "method") syntax instead in E:\imeso\web\Administration\data\xpath.class.php on line 2216 PHP Warning: The call_user_method() function is deprecated, use the call_user_func variety with the array(&$obj, "method") syntax instead in E:\imeso\web\Administration\data\xpath.class.php on line 2216 PHP Warning: The call_user_method() function is deprecated, use the call_user_func variety with the array(&$obj, "method") syntax instead in E:\imeso\web\Administration\data\xpath.class.php on line 2216 PHP Warning: The call_user_method() function is deprecated, use the call_user_func variety with the array(&$obj, "method") syntax instead in E:\imeso\web\Administration\data\xpath.class.php on line 2216 ________________ My php file uses include ("xpath.class.php") and $xpath = new XPATH("xmlfile.xml") and calls "getData()" two times, which works fine. When using "@include()" it does not give warnings about the "call-time pass-by-reference" but still the "call_user_method() function"-warning six times. I guess this is a general problem - or am I wrong? Cheers Jan |
From: Nigel S. <nig...@us...> - 2002-01-03 01:10:30
|
> I installed the new Version 4.1.0 of PHP (well the newest is 4.1.1 of > course) and now I am getting some warnings regarding the XPath Class (no > warnings with Version 4.0.6!): > ______________ > > If you would like to enable call-time pass-by-reference, you can set > allow_call_time_pass_reference to true in your INI file. However, future > versions may not support this any longer. in <snip> > E:\imeso\web\Administration\data\xpath.class.php on line 2216 > ________________ > > My php file uses > > include ("xpath.class.php") and > $xpath = new XPATH("xmlfile.xml") and > > calls "getData()" two times, which works fine. > > When using "@include()" it does not give warnings about the "call-time > pass-by-reference" but still the "call_user_method() function"-warning six > times. > > I guess this is a general problem - or am I wrong? https://sourceforge.net/docman/display_doc.php?docid=8196&group_id=36731 Should just be a case of altering the allow_call_time_pass_reference setting on your installation (php.ini or .htaccess). This issue has come up several times already I think. If that fails, then there was other discussion recently on the topic that might give you some insight: http://www.geocrawler.com/archives/3/16154/2001/12/0/ Cheers, Nigel =========================== For the most recent version of Php.XPath, and an archive of this list visit: http://www.sourceforge.net/projects/phpxpath |
From: J. C. <jan...@im...> - 2002-01-03 09:20:24
|
Hm, I did enable it and "allow_call_time_pass_reference" is set to "on" when I check it with phpinfo() and now the warnings about the ".. set allow_call_time_pass_reference to true .." warnings disappeared - great, thank's! But I still get this bunch of other deprecation warnings ".. call_user_method() .." and before searching though the archive (well, at least I searched for a search-function and did not find it) I just post my problem again: PHP Warning: The call_user_method() function is deprecated, use the call_user_func variety with the array(&$obj, "method") syntax instead in E:\imeso\web\Administration\data\xpath.class.php on line 2216 PHP Warning: The call_user_method() function is deprecated, use the call_user_func variety with the array(&$obj, "method") syntax instead in E:\imeso\web\Administration\data\xpath.class.php on line 2216 PHP Warning: The call_user_method() function is deprecated, use the call_user_func variety with the array(&$obj, "method") syntax instead in E:\imeso\web\Administration\data\xpath.class.php on line 2216 PHP Warning: The call_user_method() function is deprecated, use the call_user_func variety with the array(&$obj, "method") syntax instead in E:\imeso\web\Administration\data\xpath.class.php on line 2216 PHP Warning: The call_user_method() function is deprecated, use the call_user_func variety with the array(&$obj, "method") syntax instead in E:\imeso\web\Administration\data\xpath.class.php on line 2216 PHP Warning: The call_user_method() function is deprecated, use the call_user_func variety with the array(&$obj, "method") syntax instead in E:\imeso\web\Administration\data\xpath.class.php on line 2216 Any advice? Thank's a lot!!! Cheers Jan > -----Ursprüngliche Nachricht----- > Von: php...@li... > [mailto:php...@li...]Im Auftrag von Nigel > Swinson > Gesendet: Donnerstag, 3. Januar 2002 02:08 > An: php...@li... > Betreff: Re: Problems with PHP Version 4.1.0 ??? > > > > I installed the new Version 4.1.0 of PHP (well the newest is 4.1.1 of > > course) and now I am getting some warnings regarding the XPath Class (no > > warnings with Version 4.0.6!): > > ______________ > > > > If you would like to enable call-time pass-by-reference, you can set > > allow_call_time_pass_reference to true in your INI file. However, future > > versions may not support this any longer. in > > <snip> > > > E:\imeso\web\Administration\data\xpath.class.php on line 2216 > > ________________ > > > > My php file uses > > > > include ("xpath.class.php") and > > $xpath = new XPATH("xmlfile.xml") and > > > > calls "getData()" two times, which works fine. > > > > When using "@include()" it does not give warnings about the "call-time > > pass-by-reference" but still the "call_user_method() > function"-warning six > > times. > > > > I guess this is a general problem - or am I wrong? > > https://sourceforge.net/docman/display_doc.php?docid=8196&group_id=36731 > > Should just be a case of altering the > allow_call_time_pass_reference setting > on your installation (php.ini or .htaccess). This issue has come > up several > times already I think. If that fails, then there was other discussion > recently on the topic that might give you some insight: > > http://www.geocrawler.com/archives/3/16154/2001/12/0/ > > Cheers, > > Nigel > > =========================== > For the most recent version of Php.XPath, and an archive of this > list visit: > http://www.sourceforge.net/projects/phpxpath > > > > > _______________________________________________ > Phpxpath-users mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phpxpath-users > |
From: Nigel S. <nig...@us...> - 2002-01-03 13:07:00
|
> But I still get this bunch of other deprecation warnings ".. > call_user_method() .." and before searching though the archive (well, at > least I searched for a search-function and did not find it) I just post my > problem again: Ah, yeah, that'll be fixed in the next version. It's actually already fixed, so if you are happy to risk it then if you grab the latest version from CVS then this error should also go away :o) Nigel =========================== For the most recent version of Php.XPath, and an archive of this list visit: http://www.sourceforge.net/projects/phpxpath |
From: J. C. <jan...@im...> - 2002-01-16 12:32:41
|
Hi !!! I think this problem is already known - but I could not find anything in the latest messages: When I try put the value "0" into a node it just gives me: <selectvalue/>0 instead of: <selectvalue>0</selectvalue> ------------ The test.php file: ------------------------------ <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <? require_once("xpath.class.php"); $xmlfile="file.xml"; $xpath = new XPATH($xmlfile); if (isset($HTTP_POST_VARS["SUBMIT"])){ $xpath->replaceData("/DogTag[1]/selectvalue[1]",$HTTP_POST_VARS["select"]); $xpath->exportToFile($xmlfile,'','<?xml version="1.0" encoding="iso-8859-1"'.'?'.'>'); } ?> <body bgcolor="#FFFFFF"> <form method="post" action=""> <select name="select"> <option value="0" <? if ($xpath->getData("/DogTag[1]/selectvalue[1]")==0){ echo "selected";}?>>0</option> <option value="1" <? if ($xpath->getData("/DogTag[1]/selectvalue[1]")==1){ echo "selected";}?>>1</option> </select> <input type="submit" name="SUBMIT" value="Submit"> </form> </body> </html> ------------ The file.xml file: ------------------------------ <?xml version="1.0" encoding="iso-8859-1"?> <DogTag> <selectvalue>1</selectvalue> </DogTag> ---------------------------------------------------------------- By the way: 565 $xmlString = $this->exportAsXml($absoluteXPath); //Nothing modified here 566 $newline="\n"; //New 567 if (!fwrite($hFile, $xmlHeader.$newline.$xmlString)) { //New makes the head of the written xml look nicer (new Line after <? ... ?> part). Ok, till next time ... Jan |
From: Nigel S. <nig...@us...> - 2002-01-17 00:39:12
|
> I think this problem is already known - but I could not find anything in the > latest messages: > When I try put the value "0" into a node it just gives me: > > <selectvalue/>0 > > instead of: > > <selectvalue>0</selectvalue> Fixed in CVS revision 1.51 (mid december). If this bug is a "showstopper" for you, then you might want to get the latest version from CVS. Thanks for the very complete bug report! :o) > By the way: > > 565 $xmlString = $this->exportAsXml($absoluteXPath); //Nothing modified > here > 566 $newline="\n"; //New > 567 if (!fwrite($hFile, $xmlHeader.$newline.$xmlString)) { //New > > makes the head of the written xml look nicer (new Line after <? ... ?> > part). That whole section of code needs review, as there seem to be about three different models that we should be considering when dealing with whitespace. Bin all, pretty print and preserve. I'm still trying to focus on "bugs" though, and a decent test harness, so this "review" might not be for a while yet.... Cheers, Nigel |
From: Luc Saint-E. <lu...@sa...> - 2002-01-17 08:01:41
|
Hello all, To learn how to produce (and no more how to read) XML files from xpath.class.php, I'm writing some kind of little instant messenger system. My first goal is too have each new connected user added in a connectes.xml file the file is very simple <connectes> <user name="theuserloginname" intime="timeofarrival"> </connectes> Login name is known and timeofarrival is a simple time() Here is an abstract of my code (part of a switch) -------------------------- default : // display connected user listing $xPath->reset(); $connecte = array(); $xPath->importFromFile('xml_files/connectes.xml'); $aResult = $xPath->evaluate('/connectes/user'); foreach ( $aResult as $user ) { $t = $xPath->getAttributes($user); array_push ($connecte, array('name' =>$t['name'])); } // Add curent user to this list $xPath->appendChild('/connectes[1]', 'user'); $attributes['name'] = $user_name; $attributes['intime'] = time(); $xPath->setAttributes('/connectes[1]/user[1]', $attributes); $xPath->exportToFile('xml_files/connectes.xml','','<?xml version="1.0" encoding="iso-8859-1"'.'?'.'>'); $is_connected = 'oui'; $session_register("is_connected"); At the firdst invocation every thing goes fine But if I open another browser (to simulate twoi user I use netscape for one and MIE for the other) the seond user is added to my connectd.xml file but the first one is emptied here is the file Step one : no one is connected ======================== <?xml version="1.0" encoding="iso-8859-1"?> <connectes/> Step two first user connected ======================== <?xml version="1.0" encoding="iso-8859-1"?> <connectes> <user name="user1" intime="1011253765"/> </connectes> Step three a second user is connected =============================== <?xml version="1.0" encoding="iso-8859-1"?> <connectes> <user name="user2" intime="1011253789"/> <user/> </connectes> As you can see the second user is added to the file.. but the first is emptied. Where did I screw up ??? Any idea ? Luc |
From: J. C. <jan...@im...> - 2002-01-17 09:20:22
|
Instead of: > $xPath->appendChild('/connectes[1]', 'user'); You need to get the path to the new Child: $newchild=$xPath->appendChild('/connectes[1]', 'user'); Then you can work with it: $attributes['name'] = $user_name; $attributes['intime'] = time(); $xPath->setAttributes($newchild, $attributes); That should do it, I guess Jan > > $xPath->exportToFile('xml_files/connectes.xml','','<?xml > version="1.0" encoding="iso-8859-1"'.'?'.'>'); > $is_connected = 'oui'; > $session_register("is_connected"); > > At the firdst invocation every thing goes fine > > But if I open another browser (to simulate twoi user I use > netscape for one > and MIE for the other) the seond user is added to my connectd.xml > file but > the first one is emptied > > here is the file > > Step one : no one is connected > ======================== > <?xml version="1.0" encoding="iso-8859-1"?> > <connectes/> > > Step two first user connected > ======================== > <?xml version="1.0" encoding="iso-8859-1"?> > <connectes> > <user name="user1" intime="1011253765"/> > </connectes> > > Step three a second user is connected > =============================== > <?xml version="1.0" encoding="iso-8859-1"?> > <connectes> > <user name="user2" intime="1011253789"/> > <user/> > </connectes> > > As you can see the second user is added to the file.. but the > first is emptied. > > Where did I screw up ??? > > Any idea ? > > Luc > > > _______________________________________________ > Phpxpath-users mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phpxpath-users > |
From: Luc Saint-E. <lu...@sa...> - 2002-01-17 09:49:07
|
Thanks Jan, Its exactly where my error was.. thanks a lot.... At 10:14 17/01/02 +0100, you wrote: >Instead of: > > > $xPath->appendChild('/connectes[1]', 'user'); > >You need to get the path to the new Child: > > $newchild=$xPath->appendChild('/connectes[1]', 'user'); > >Then you can work with it: > > $attributes['name'] = $user_name; > $attributes['intime'] = time(); > $xPath->setAttributes($newchild, $attributes); > >That should do it, I guess > >Jan |
From: Luc Saint-E. <lu...@sa...> - 2002-01-17 13:26:03
|
Hello, Still in my "lets's learn toproduce xml files process", my problem is solved (thanks Jan) with attributes but now I fail when I want to ad nodes. The goal now is to ad a new message in the messages.xml file. a message is of the form : <liste> <message> <is_read>no</is_read> <texte>text of the message</texte> <expediteur>username_of_the_sender</expediteur> <destinataire>usernameof the destination</destinataire> <date>1011272580</date> </message> </liste> With the following bit of code the entry is done, but a lot of errors are sent like : *************** XPath error in XPath.class.php:4659 The /liste[1]/message[4]/is_read[1] does not have a text node at position 0 XPath error in XPath.class.php:4659 The /liste[1]/message[4]/texte[1] does not have a text node at position 0 XPath error in XPath.class.php:4659 The /liste[1]/message[4]/expediteur[1] does not have a text node at position 0 XPath error in XPath.class.php:4659 The /liste[1]/message[4]/destinataire[1] does not have a text node at position 0 XPath error in XPath.class.php:4659 The /liste[1]/message[4]/date[1] does not have a text node at position 0 **************** here is my code case 'newmsgs' :$xPath->reset(); $xPath->importFromFile('xml_files/messages.xml'); $newchild=$xPath->appendChild('/liste[1]', 'message'); $newchild1=$xPath->appendChild($newchild, 'is_read'); $xPath->insertData($newchild1, 'no'); $newchild2=$xPath->appendChild($newchild, 'texte'); $xPath->insertData($newchild2, $texte); $newchild3=$xPath->appendChild($newchild, 'expediteur'); $xPath->insertData($newchild3, $expediteur); $newchild4=$xPath->appendChild($newchild, 'destinataire'); $xPath->insertData($newchild4, $destinataire); $newchild5=$xPath->appendChild($newchild, 'date'); $xPath->insertData($newchild5, time()); $xPath->exportToFile('xml_files/messages.xml','','<?xml version="1.0" encoding="iso-8859-1"'.'?'.'>'); Thanks in advance (and tons of excuses for my dummy questions) Luc |
From: Luc Saint-E. <lu...@sa...> - 2002-01-17 14:24:48
|
Hello, Forget my previous message it was apparently a problem of xpath.class.php version, I put the last dev version and it works.. Luc At 14:16 17/01/02 +0100, Luc Saint-Elie wrote: >Hello, > >Still in my "lets's learn toproduce xml files process", my problem is >solved (thanks Jan) with attributes but now I fail when I want to ad nodes. > >The goal now is to ad a new message in the messages.xml file. >a message is of the form : |
From: Luc Saint-E. <lu...@sa...> - 2002-01-17 16:13:40
|
Hello (again..)) I've been away from xpath.class.php for some time and I'm trying without=20 succes very simple things with the last dev version I use /Xpath-develop/XPath.class.php (from the cvs) here is my xml file : ----------------------------------------------------------------------------= ---- <?xml version=3D"1.0" encoding=3D"iso-8859-1"?> <liste> <message> <is_read>no</is_read> <texte>qfdmqkjsdmlfkqkdf</texte> <expediteur>userone</expediteur> <destinataire>usertwo</destinataire> <date>1011277311</date> </message> <message> <is_read>no</is_read> <texte>bon salut ma poule</texte> <expediteur>usertwo</expediteur> <destinataire>userone</destinataire> <date>1011278602</date> </message> <message> <is_read>no</is_read> <texte>kgluylutglk=E8utky(kdyrkglu-iuykuyd(u=E8</texte> <expediteur>userone</expediteur> <destinataire>usertwo</destinataire> <date>1011279657</date> </message> </liste> ----------------------------------------------------------------------------= -------- here is a dam simple bit of code : ----------------------------------------------------------------------------= ----------- require_once 'lib/XPath.class.php'; $xPath =3D new XPath(); $xPath->importFromFile('xml_files/messages.xml'); $msglist =3D $xPath->evaluate('/liste/message'); print_r($msglist); echo '<br>'; foreach ( $msglist as $msg ) { echo $msg.'<br>'; $is_read =3D $xPath->getData($msg.'/is_read[1]'); echo $is_read.'<br>'; $texte =3D $xPath->getData($msg.'/texte[1]'); echo $texte.'<br>'; $expediteur =3D $xPath->getData($msg.'/expediteur[1]'); echo $expediteur.'<br>'; } echo $xPath->exportAsHtml(); ----------------------------------------------------------------------------= ------------- Dump of the evaluate() is ok : $msglist Array ( [0] =3D> /liste[1]/message[1] [1] =3D> /liste[1]/message[2] [2] =3D> /liste[1]/message[3] ) Dump of exportAsHtml() is OK But all getData() variables are empty... Any direction ? Luc |
From: Luc Saint-E. <lu...@sa...> - 2002-01-17 17:13:26
|
At 17:33 17/01/02 +0100, you wrote: >I am also fighting with the develop version the whole day now. > >getData goes to wholeText() goes to substringData() goes to _setContent() The fun part is that the deprecated get_content() works... Luc |
From: Luc Saint-E. <lu...@sa...> - 2002-01-18 07:57:38
|
Hello, With latest CVS is there a way (a setting switch) to get <tag><![CDATA[ content ]]></tag> instead of <tag>content </tag> When doing : $xPath->replaceData($path,$content); The reason is that I'm French and not only we eat frogs but we use a lot of extended characters Luc |
From: Nigel S. <nig...@us...> - 2002-01-18 18:41:57
|
> With latest CVS is there a way (a setting switch) to get > > <tag><![CDATA[ content ]]></tag> > > instead of > > <tag>content </tag> > > When doing : > > $xPath->replaceData($path,$content); > > The reason is that I'm French and not only we eat frogs but we use a lot of > extended characters Again, a known issue, planned to be improved upon in the future, to be honest I'm not sure how we currently deal with CDATA, just that it is inadequate. :o) Nigel =========================== For the most recent version of Php.XPath, V2.x, and an archive of this list visit: http://www.sourceforge.net/projects/phpxpath |
From: J. C. <jan...@im...> - 2002-01-17 16:40:02
Attachments:
XPath.class.zip
|
I am also fighting with the develop version the whole day now. getData goes to wholeText() goes to substringData() goes to _setContent() Still confused? Something with $replace=TRUE does fix it ... I did some changes (too long to explaine), just try this file (but backup your old one!). Did ever someone try to do getData() of <node>0</node> ????? It does not work :( and I can't solve it ... I should go home maybe and watch TV ... > -----Ursprüngliche Nachricht----- > Von: php...@li... > [mailto:php...@li...]Im Auftrag von Luc > Saint-Elie > Gesendet: Donnerstag, 17. Januar 2002 17:09 > An: php...@li... > Betreff: A little bit confused > > > Hello (again..)) > > I've been away from xpath.class.php for some time and I'm trying without > succes very simple things with the last dev version > > I use > /Xpath-develop/XPath.class.php (from the cvs) > > > here is my xml file : > ------------------------------------------------------------------ > -------------- > <?xml version="1.0" encoding="iso-8859-1"?> > <liste> > <message> > <is_read>no</is_read> > <texte>qfdmqkjsdmlfkqkdf</texte> > <expediteur>userone</expediteur> > <destinataire>usertwo</destinataire> > <date>1011277311</date> > </message> > <message> > <is_read>no</is_read> > <texte>bon salut ma poule</texte> > <expediteur>usertwo</expediteur> > <destinataire>userone</destinataire> > <date>1011278602</date> > </message> > <message> > <is_read>no</is_read> > <texte>kgluylutglkèutky(kdyrkglu-iuykuyd(uè</texte> > <expediteur>userone</expediteur> > <destinataire>usertwo</destinataire> > <date>1011279657</date> > </message> > </liste> > ------------------------------------------------------------------ > ------------------ > > here is a dam simple bit of code : > > ------------------------------------------------------------------ > --------------------- > require_once 'lib/XPath.class.php'; > $xPath = new XPath(); > $xPath->importFromFile('xml_files/messages.xml'); > $msglist = $xPath->evaluate('/liste/message'); > print_r($msglist); > echo '<br>'; > foreach ( $msglist as $msg ) { > echo $msg.'<br>'; > $is_read = $xPath->getData($msg.'/is_read[1]'); > echo $is_read.'<br>'; > $texte = $xPath->getData($msg.'/texte[1]'); > echo $texte.'<br>'; > $expediteur = $xPath->getData($msg.'/expediteur[1]'); > echo $expediteur.'<br>'; > } > echo $xPath->exportAsHtml(); > ------------------------------------------------------------------ > ----------------------- > > Dump of the evaluate() is ok : > > $msglist Array > ( > [0] => /liste[1]/message[1] > [1] => /liste[1]/message[2] > [2] => /liste[1]/message[3] > ) > > Dump of exportAsHtml() is OK > > But all getData() variables are empty... > > Any direction ? > > Luc > > > _______________________________________________ > Phpxpath-users mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phpxpath-users |
From: Nigel S. <nig...@us...> - 2002-01-17 23:58:43
Attachments:
messages.xml
Junk.php
|
> I am also fighting with the develop version the whole day now. > > getData goes to wholeText() goes to substringData() goes to _setContent() > > Still confused? Something with $replace=TRUE does fix it ... I did some > changes (too long to explaine), just try this file (but backup your old > one!). > > Did ever someone try to do getData() of > <node>0</node> > ????? It does not work :( and I can't solve it ... I just tried this with the latest from CVS and it worked, so get the latest version, and let us know if there's still a problem :o) The attached two files give the result: ========================================= List of messages.Array ( [0] => /liste[1]/message[1] ) ---------------------------------------------------------------------------- ----/liste[1]/message[1]012------------------------------------------------- -------------------------------<liste> <message> <is_read>0</is_read> <texte>1</texte> <expediteur>2</expediteur> </message> </liste> ========================================= > I should go home maybe and watch TV ... Yeah "Indiana Jones and the Last Crusade" was on TV tonight, so bang went my plans for spending two hours on the test harness :oD Nigel |
From: Nigel S. <nig...@us...> - 2002-01-17 23:51:01
|
> At 17:33 17/01/02 +0100, you wrote: > >I am also fighting with the develop version the whole day now. > > > >getData goes to wholeText() goes to substringData() goes to _setContent() > > The fun part is that the deprecated get_content() works... Simple bug, just found it. In getData() we had: $this->wholeText($absoluteXPath); instead of: return $this->wholeText($absoluteXPath); Oops :o) You'll find the fix in CVS. Nigel |
From: Luc Saint-E. <lu...@sa...> - 2002-01-18 00:05:29
|
Nigel, I tried latest CVS.. it works Luc At 23:50 17/01/02 +0000, you wrote: > > At 17:33 17/01/02 +0100, you wrote: > > >I am also fighting with the develop version the whole day now. > > > > > >getData goes to wholeText() goes to substringData() goes to _setContent() > > > > The fun part is that the deprecated get_content() works... > >Simple bug, just found it. In getData() we had: > > $this->wholeText($absoluteXPath); > >instead of: > > return $this->wholeText($absoluteXPath); > >Oops :o) > >You'll find the fix in CVS. > >Nigel |