phpxpath-users Mailing List for Php.XPath (Page 2)
Brought to you by:
bs_php,
nigelswinson
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(346) |
Nov
(8) |
Dec
(21) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(30) |
Feb
(13) |
Mar
|
Apr
(3) |
May
(70) |
Jun
(26) |
Jul
(48) |
Aug
(22) |
Sep
(1) |
Oct
(4) |
Nov
|
Dec
|
2003 |
Jan
(3) |
Feb
(3) |
Mar
(11) |
Apr
(3) |
May
(4) |
Jun
(3) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2004 |
Jan
(4) |
Feb
(2) |
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(12) |
Aug
(8) |
Sep
(2) |
Oct
(2) |
Nov
(3) |
Dec
|
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
2006 |
Jan
(3) |
Feb
(7) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: Peter R. <php...@pe...> - 2004-08-23 16:04:14
|
On Monday 23 Aug 2004 16:56, Peter Robins wrote: > getData() is for getting > the contents of a data node where 'data node' means 'text node'. 'A text node always has at least one character of data.' |
From: Peter R. <php...@pe...> - 2004-08-23 15:56:30
|
On Friday 20 Aug 2004 13:11, Jani Pohjanraito wrote: > However, I cannot even overcome the simple first step, displaying the whole > tree. I *can* however access the contents of the single nodes of the tree > (like this: ' $txt = $xpath->getData("article/teksti"); '). > > No matter what I try there's simply "XPath error in XPath.class.php:5813 > The supplied xPath 'root[1]' does not *uniquely* describe a node in the xml > document.Not unique xpath-query, matched 0-times." The code follows: > > I have this simple XML-file that depicts an article: > > <?xml version="1.0" encoding="UTF-8" ?> > <article> > <otsake>Title Here</otsake> > <teksti>Yabba Pala Plah Blah blaa. Gabber gabba yadda wabba. Shaba dada > baba.</teksti> > <pvm>19082004</pvm> > <contact>fa...@ch...</contact> > </article> > > And then I tested Xpath 3.5 with this code: > > require_once("XPath.class.php"); > $xpath = new XPath("vi_articles.xml"); //the xml file above > //Display all the content > $art = $xpath->getData("root[1]"); > echo "<hr>koko artikkeli:<br> $art<hr>"; > .. > > In place of 'root[1]' I also tried '/', '/article', 'article', > 'article[0]', 'article[1]', '/root', '/root[1]' (and several hundred other > variations it seems 8) ) > > What gives? How to get to the whole tree so I can 'echo' it? not sure I understand what you are trying to do. getData() is for getting the contents of a data node. Your <article> node is not a data node. You can do getData("article[1]") but it will be empty. If you want a list of the children of the <article> node, do an evaluate/match on /article[1]/* or whatever; this will return a nodeset array which you can then process with a do-loop or whatever on the individual child nodes, for example, to get their data contents. |
From: Jani P. <yj...@ku...> - 2004-08-20 12:11:26
|
I'm very interested in using XPath with my projects to handle XML. So I decided to do some simple testing. However, I cannot even overcome the simple first step, displaying the whole tree. I *can* however access the contents of the single nodes of the tree (like this: ' $txt = $xpath->getData("article/teksti"); '). No matter what I try there's simply "XPath error in XPath.class.php:5813 The supplied xPath 'root[1]' does not *uniquely* describe a node in the xml document.Not unique xpath-query, matched 0-times." The code follows: I have this simple XML-file that depicts an article: <?xml version="1.0" encoding="UTF-8" ?> <article> <otsake>Title Here</otsake> <teksti>Yabba Pala Plah Blah blaa. Gabber gabba yadda wabba. Shaba dada baba.</teksti> <pvm>19082004</pvm> <contact>fa...@ch...</contact> </article> And then I tested Xpath 3.5 with this code: require_once("XPath.class.php"); $xpath = new XPath("vi_articles.xml"); //the xml file above //Display all the content $art = $xpath->getData("root[1]"); echo "<hr>koko artikkeli:<br> $art<hr>"; .. In place of 'root[1]' I also tried '/', '/article', 'article', 'article[0]', 'article[1]', '/root', '/root[1]' (and several hundred other variations it seems 8) ) What gives? How to get to the whole tree so I can 'echo' it? Thanks for reading, j |
From: Nigel S. <nig...@us...> - 2004-08-13 14:21:57
|
Release notes: http://www.carrubbers.org/scripts/php/xpath/Changes.html Project home page: http://sourceforge.net/projects/phpxpath Substantial corrections made to the parsing and processing of XPath = queries. This makes Php.XPath adhere much more accurately to the = standard, and makes it search a little quicker too. Also updated to = work with PHP5. Given the support for XPath in PHP5, this may well be the last release = of Php.XPath? It certainly seems to be very very stable now, and I will = likely still be using it for the next couple of years, so keep the bug = reports coming and I'll be happy to do another release if required. :o) Cheers all, Nigel |
From: Nigel S. <nig...@us...> - 2004-08-09 22:11:43
|
You need to these functions: a.. http://www.carrubbers.org/scripts/php/xpath/doc/#importFromFile = (or perhaps = http://www.carrubbers.org/scripts/php/xpath/doc/#importFromString) b.. http://www.carrubbers.org/scripts/php/xpath/doc/#match with some = XPath along the lines of \\user[location =3D USA] c.. http://www.carrubbers.org/scripts/php/xpath/doc/#getAttributes But to be honest, you might be better off using XSLT. There you can do = an xsl:sort. But it sounds like you might be trying to use XML as a database format, = in which case you possibly want to have a look at the phpxmldb project: = http://www.carrubbers.org/scripts/php/xmldb/ where you have an API = called Search() and SortSearch(). Nigel=20 ----- Original Message -----=20 From: BeDii KaYa=20 To: php...@li...=20 Sent: Saturday, August 07, 2004 1:23 PM Subject: URGENT! please help me at parsing multiple data looply I have an XML like <main> <result> [true / false] </result> <userlist> <user id=3D"xxxxxxx"> <regdate>19/2/2004</date> <reg_time>11:39:50</start_time> <location>United Kingdom</location> </user>=20 <user id=3D"xxxxxxx"> <regdate>19/3/2004</date> <reg_time>01:39:50</start_time> <location>USA</location> </user>=20 .. .. .. . =20 . </userlist> </main> How can i parse this XML document in PHP by categorized as Country? = In other words i need parse it looply.. PLEASE HELP ME! I WILL BE GLAD! -------------------------------------------------------------------------= ----- Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! |
From: BeDii K. <lin...@ya...> - 2004-08-07 12:23:28
|
I have an XML like <main> <result> [true / false] </result> <userlist> <user id="xxxxxxx"> <regdate>19/2/2004</date> <reg_time>11:39:50</start_time> <location>United Kingdom</location> </user> <user id="xxxxxxx"> <regdate>19/3/2004</date> <reg_time>01:39:50</start_time> <location>USA</location> </user> .. .. .. . . </userlist> </main> How can i parse this XML document in PHP by categorized as Country? In other words i need parse it looply.. PLEASE HELP ME! I WILL BE GLAD! --------------------------------- Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! |
From: J. C. <jan...@im...> - 2004-07-26 13:16:48
|
Hi my problem is solved. The code now looks like the following, maybe it can help also someone else. Cheers Jan require_once("include/XPath.class.php"); $xpath=new XPath($f_dir.$file."_web.xml"); /* ..$xpath=new XPath(); ..$xpath->setSkipWhiteSpaces(); ..$xpath->importFromFile($f_dir.$file."_web.xml"); */ // ACTIONS: if(isset($_POST["aktion"])){ ..$path=$_POST["lokation_id"]; ..$target_path=$_POST["target_path"]; ..switch($_POST["aktion"]){ ....case "DEL": ......$xpath->removeChild($path,true); ......$pos=strrpos($path,"/"); ......$path=substr($path,0,$pos); ......break; ....case "NEW": ......if ($_POST["exelmode"]=="true"){ ........//Insert Nodes from List in Textarea ........$namen=split("\r\n",$_POST["atarea"]); ........$first=true; ........foreach($namen as $name){ ..........if ($name=="") continue; ..........if($first){ ............$path_temp=$xpath->appendChild($path,"<data name=\"".$name."\">".$_POST["text_entry"]."</data>"); ............$first=false; ..........}else ............$xpath->appendChild($path,"<data name=\"".$name."\">".$_POST["text_entry"]."</data>"); ........} ........$path=$path_temp; ......}else ........//normal new entry ........$path=$xpath->appendChild($path,"<data name=\"".$_POST["bezeichnung"]."\">".$_POST["text_entry"]."</data>"); ......break; ....case "EDIT": ......$xpath->setAttribute($path,"name",$_POST["bezeichnung"]); ......$xpath->replaceData($path,$_POST["text_entry"]); ......break; ....case "CLONE": ......$clonedNode=&$xpath->cloneNode($path,FALSE); ......$xpath->insertBefore($path, $clonedNode,true,true); ......break; ....case "PASTE_INTO": ......$clonedNode=&$xpath->cloneNode($target_path,FALSE); ......$path_temp=$xpath->appendChild($path, $clonedNode, FALSE, TRUE); // insert here ......break; ....case "UP": ......$clonedNode=&$xpath->cloneNode($path,FALSE); // -> duplicate ......$xpath->removeChild($path, FALSE); // -> take away ......$xpath->insertBefore($target_path, $clonedNode, FALSE, TRUE); // insert here ......$path=$target_path; ......break; ....case "DOWN": ......if ($_POST["toolkit"]=="append"){ // node append to parent node (it is the last element) ........$clonedNode=&$xpath->cloneNode($path,FALSE); // -> duplicate ........$path_temp=$xpath->appendChild($target_path, $clonedNode, FALSE, TRUE); // insert here ........$xpath->removeChild($path, TRUE); // -> take away ........$pos1=strrpos($path_temp,"["); ........$pos2=strrpos($path_temp,"]")-1; ........$pos=substr($path_temp,$pos1+1,strlen($path_temp)-$pos2); ........$path=substr($path_temp,0,$pos1)."[".($pos-1)."]"; ......}else{ ........$clonedNode=&$xpath->cloneNode($target_path,FALSE); // -> duplicate ........$xpath->removeChild($target_path, FALSE); // -> take away ........$xpath->insertBefore($path, $clonedNode, FALSE,TRUE); // insert here ........$path=$target_path; ......} ......break; ..} ..copy($f_dir.$file."_web.xml",$f_dir.time()."_".$file."_web.xml"); ..$xpath->exportToFile($f_dir.$file."_web.xml",'','<?xml version="1.0" encoding="iso-8859-1"'.'?'.'>'); } > -----Ursprungliche Nachricht----- > Von: php...@li... > [mailto:php...@li...]Im Auftrag von J. > Carmanns > Gesendet: Mittwoch, 21. Juli 2004 15:29 > An: php...@li... > Betreff: change Position of a Node > > > Can anyone show me a smart way to move a complete node-structure > up or down > in the xml document? > > $xml="<root><A>abc</A><B>def</B></root>"; > ... > move("/root/B[1]","up"); > echo $xml; //should give: <root><B>def</B><A>abc</A></root> > > move("/root/B[1]","down"); > echo $xml; //should give: <root><A>abc</A><B>def</B></root> > > function move($xpath,$direction){ > global $XPathObject; > //??? > } > > I am thinking about deleting and re-inserting all the nodes in the parent > node but there must be an easy way, or not? Can I just change the > two index > keys in the xpath array? > > Has anyone coded something for this problem before? > > Thanks for any help! > > Cheers > Jan > > > > ------------------------------------------------------- > This SF.Net email is sponsored by BEA Weblogic Workshop > FREE Java Enterprise J2EE developer tools! > Get your free copy of BEA WebLogic Workshop 8.1 today. > http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click > _______________________________________________ > Phpxpath-users mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phpxpath-users |
From: Peter R. <php...@pe...> - 2004-07-24 13:09:52
|
On Saturday 24 Jul 2004 12:49, Nigel Swinson wrote: > This was fixed quite a while ago but has not yet been released as a new > version. If you get the latest version direct from CVS you should find > that not only is this problem fixed, yup, that seems to fix it. Another difference that may catch the unwary is that the useCases testbench uses the HTTP_*_VARS, so won't work if register_long_arrays in php.ini is off. However, I doubt it's worth your changing that. > but it also goes quite a lot faster too :o) I've always found that the slowness of evaluate/match is phpxpath's biggest problem. You don't notice if you're only accessing one or two nodes, but I have 1 file where each node has a unique id attribute which is the xpath key. phpxpath doesn't like this at all. It's quite a large file, and updating a large no of nodes can literally take several minutes! |
From: Nigel S. <nig...@us...> - 2004-07-24 11:46:45
|
This was fixed quite a while ago but has not yet been released as a new = version. If you get the latest version direct from CVS you should find = that not only is this problem fixed, but it also goes quite a lot faster = too :o) When I get time to breathe, I will run the release process (possibly for = the last time), but it takes several hours, and I'm quite busy at work = just now. :o( Nigel =20 ----- Original Message -----=20 From: "Peter Robins" <php...@pe...> To: <php...@li...> Sent: Thursday, July 22, 2004 9:19 PM Subject: Re: phpxpath and php5 > > I've just been testing my phpxpath scripts in php5 and have to say = I've not > > found one that works :-(( For example, 'PHP Fatal error: Cannot = re-assign > > $this in /test/scripts/XPath.class.php on line 4614' > > which it seems is one of the 'undocumented features' of the new = version > > (see user comment at > > http://www.php.net/manual/en/migration5.incompatible.php) > > > > What's the plan? Is phpxpath going to be left as is to wither with = php4, or > > will it be updated to work on php5? |
From: Peter R. <php...@pe...> - 2004-07-22 20:19:37
|
On Thursday 22 Jul 2004 20:19, Peter Robins wrote: > With the hugely improved xml capabilities in php5, I expect phpxpath will > slowly become redundant. However, it'll be a while before scripts are > changed, and also until php5 is widely installed in production > environments, so those of us who have a script running on several servers > may have it on php4 and on php5. > > I've just been testing my phpxpath scripts in php5 and have to say I've not > found one that works :-(( For example, 'PHP Fatal error: Cannot re-assign > $this in /test/scripts/XPath.class.php on line 4614' > which it seems is one of the 'undocumented features' of the new version > (see user comment at > http://www.php.net/manual/en/migration5.incompatible.php) > > What's the plan? Is phpxpath going to be left as is to wither with php4, or > will it be updated to work on php5? following on from this, it seems this error is given in php5 whether or not the code is executed or not. My workaround for the moment is to comment out line 4614. An odd thing to do anyway - set an object to a boolean value? hmmmm . . . |
From: Peter R. <php...@pe...> - 2004-07-22 19:19:26
|
With the hugely improved xml capabilities in php5, I expect phpxpath will slowly become redundant. However, it'll be a while before scripts are changed, and also until php5 is widely installed in production environments, so those of us who have a script running on several servers may have it on php4 and on php5. I've just been testing my phpxpath scripts in php5 and have to say I've not found one that works :-(( For example, 'PHP Fatal error: Cannot re-assign $this in /test/scripts/XPath.class.php on line 4614' which it seems is one of the 'undocumented features' of the new version (see user comment at http://www.php.net/manual/en/migration5.incompatible.php) What's the plan? Is phpxpath going to be left as is to wither with php4, or will it be updated to work on php5? |
From: J. C. <jan...@im...> - 2004-07-22 07:44:28
|
Dear Victor use $xpathEn->importFromString($nick,$xpath) only with "->" you can access the function because it is a pointer and not a normal member function can anyone help me with the move XML element up and down problem? Thanks! Cheers Jan -----Ursprüngliche Nachricht----- Von: php...@li... [mailto:php...@li...]Im Auftrag von Victor Rodríguez Gesendet: Mittwoch, 21. Juli 2004 17:00 An: php...@li... Betreff: Call to undefined function: importFromString() Hi, I'm trying to call the function XPathEngine.importFromString() and the result is like this: Fatal error: Call to undefined function: importfromstring() in d:\desenvol\055_op_hotel_continental\proves\testre.php on line 11 I don't understand why because the XPathEngine Object is created correctly... Shuold I did something wrong?? <?php include 'PHPXPath/XPath.class.php'; $nick = "<xmlDoc><accio>'loginPSW'</accio><user>SYSTEM</user><text><nick>manolo</nic k><psw>manolo</psw></text></xmlDoc>"; $xmlOpt = array(XML_OPTION_CASE_FOLDING => FALSE, XML_OPTION_SKIP_WHITE => TRUE); $xpathEn = new XPathEngine($xmlOpt); echo "xpathEn: " . $xpathEn . "<br>"; $b = $xpathEn.importFromString($nick, $xpath); echo "importFromString: " . $b . "<br>"; ?> Thank you very much, and sorry for my english... Best wishes... Víctor Rodríguez Ortega. |
From: <vi...@ad...> - 2004-07-22 07:25:15
|
Hi, I'm trying to call the function XPathEngine.importFromString() and the = result is like this: Fatal error: Call to undefined function: importfromstring() in = d:\desenvol\055_op_hotel_continental\proves\testre.php on line 11 I don't understand why because the XPathEngine Object is created = correctly... Shuold I did something wrong?? <?php include 'PHPXPath/XPath.class.php'; $nick =3D = "<xmlDoc><accio>'loginPSW'</accio><user>SYSTEM</user><text><nick>manolo</= nick><psw>manolo</psw></text></xmlDoc>"; $xmlOpt =3D array(XML_OPTION_CASE_FOLDING =3D> FALSE, = XML_OPTION_SKIP_WHITE =3D> TRUE); $xpathEn =3D new XPathEngine($xmlOpt); echo "xpathEn: " . $xpathEn . "<br>"; $b =3D $xpathEn.importFromString($nick, $xpath); echo "importFromString: " . $b . "<br>"; ?> Thank you very much, and sorry for my english... Best wishes... V=EDctor Rodr=EDguez Ortega. |
From: J. C. <jan...@im...> - 2004-07-21 13:26:44
|
Can anyone show me a smart way to move a complete node-structure up or down in the xml document? $xml="<root><A>abc</A><B>def</B></root>"; ... move("/root/B[1]","up"); echo $xml; //should give: <root><B>def</B><A>abc</A></root> move("/root/B[1]","down"); echo $xml; //should give: <root><A>abc</A><B>def</B></root> function move($xpath,$direction){ global $XPathObject; //??? } I am thinking about deleting and re-inserting all the nodes in the parent node but there must be an easy way, or not? Can I just change the two index keys in the xpath array? Has anyone coded something for this problem before? Thanks for any help! Cheers Jan |
From: James H. <ja...@oc...> - 2004-07-13 21:11:54
|
well with php xpath, You can get the data by using : $xpath=3D new XPath("file.xml"); $nodedata =3D $xpath->getData("/ws/result"); #this would/should return true, but if you didn't know if there was a=20 result you would have to do something like. $nodes=3D $xpath->match("/ws"); foreach ($nodes as $node){ echo $node."<br>"; #would return result $nodedata =3D $xpath->getData($node); #would return true } Now with child nodes that have children, you are in a whole different=20 ballgame, and really the documentation covers that, but basically you=20 would have to test to see if the child that returns in the loop has=20 children, and if so, dig, or make it a link, and change your node path=20= when you follow the link. Hope this helps. --James On Jul 13, 2004, at 6:52 AM, BeDii KaYa wrote: > Hi. I have an xml document which is generated with NuSOAP. I would=20 > like to parse the result of NuSOAP (xml string) with xpath and want to=20= > use it php. > =A0 > NuSOAP generates something like : > =A0 > <ws> > <result>true</result> > <login> > <session_id>XXXXX</session_id> > </login> > </ws> > =A0 > How can i parse this string and use it with php via XPATH? I have=20 > tried GetDATA, importstring, etc but failed. Please suggest me a=20 > solution for parsing the data with an example. > =A0 > Thanks for your comprehension. > > Do you Yahoo!? > New and Improved Yahoo! Mail - 100MB free storage! --James Hughbanks Mikro-Data Engineering Dept. su...@mi... 1-866-457-6287 http://www.mikro-data.net |
From: Peter R. <php...@pe...> - 2004-07-13 15:33:56
|
On Tuesday 13 Jul 2004 11:52, BeDii KaYa wrote: > Hi. I have an xml document which is generated with NuSOAP. I would like= to > parse the result of NuSOAP (xml string) with xpath and want to use it p= hp. > > NuSOAP generates something like : > > <ws> > <result>true</result> > <login> > <session_id>XXXXX</session_id> > </login> > </ws> > > How can i parse this string and use it with php via XPATH? I have tried > GetDATA, importstring, etc but failed. Please suggest me a solution for > parsing the data with an example. <?php =A0 =A0include('XPath.class.php'); =A0 =A0$xml =3D new XPath(); $xmlstring =3D "<ws> <result>true</result> <login> <session_id>XXXXX</session_id> </login> </ws>"; $xml->importFromString($xmlstring); print $xml->getData('/ws[1]/result[1]'); print $xml->getData('/ws[1]/login[1]/session_id[1]'); ?> |
From: BeDii K. <lin...@ya...> - 2004-07-13 10:52:46
|
Hi. I have an xml document which is generated with NuSOAP. I would like to parse the result of NuSOAP (xml string) with xpath and want to use it php. NuSOAP generates something like : <ws> <result>true</result> <login> <session_id>XXXXX</session_id> </login> </ws> How can i parse this string and use it with php via XPATH? I have tried GetDATA, importstring, etc but failed. Please suggest me a solution for parsing the data with an example. Thanks for your comprehension. --------------------------------- Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! |
From: BeDii K. <lin...@ya...> - 2004-07-13 10:42:43
|
Hi. I have an xml document which is generated with NuSOAP. I would like to parse the result of NuSOAP (xml string) with xpath and want to use it php. NuSOAP generates something like : <ws> <result>true</result> <login> <session_id>XXXXX</session_id> </login> </ws> How can i parse this string and use it with php via XPATH? I have tried GetDATA, importstring, etc but failed. Please suggest me a solution for parsing the data with an example. Thanks for your comprehension. --------------------------------- Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. |
From: SourceForge.net <no...@so...> - 2004-04-26 19:26:58
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=2541349 By: nigelswinson It's best to set setSkipWhiteSpaces() before you do your import, as it's during the import process that it sets the whitespace that should go around the elements, but the value is also used on export to reconstruct the file to your liking. So if you have SkipWhiteSpaces on for the import, then it will bin all the whitespaces, then turn it off for the export, and it won't "pretty print" the output, but output as was imported. Please post further support queries by email to the (archived) users list, where your issue will be read by many other Php.XPath users. Cheers, Nigel ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=114574 |
From: SourceForge.net <no...@so...> - 2004-04-24 16:26:00
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=2538356 By: bhornedo Hello Forum! I'm trying to figure out why when I setSkipWhiteSpaces(false) and do an exportToFile the resulting file contains NO indentation or readability formatting? All of the tags and data are just written in series. The file works fine and is usable, but trying to read it gives me a headache. Am I missing a setting to output the file WITH formatting? Any help would be great! ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=114574 |
From: Peter R. <php...@pe...> - 2004-03-28 12:49:59
|
On Sunday 28 Mar 2004 02:49, ktt wrote: > I have an XML file like > > <orchard> > <flora> > <flower>red</flower> > <stem>green</stem> > </flora> > > <flora> > <flower>red</flower> > <stem>pale</stem> > </flora> > > <flora> > <flower>blue</flower> > <stem>pale</stem> > </flora> > </orchard> > > > The aim is to display all <flora> nodes if subnode of > it > has a value "red". > > I would like to use > function _handleFunction_contains($arguments, > $context) > and use a query "//flora[contains(.,'red')]" . evaluate xpath syntax would be something like //flora//*[contains(.,'red')] i.e. give me descendants of all flora nodes which contain 'red' <name>fred</name> also contains 'red' ;) |
From: ktt <kes...@ya...> - 2004-03-28 01:49:37
|
I have an XML file like <orchard> <flora> <flower>red</flower> <stem>green</stem> </flora> <flora> <flower>red</flower> <stem>pale</stem> </flora> <flora> <flower>blue</flower> <stem>pale</stem> </flora> </orchard> The aim is to display all <flora> nodes if subnode of it has a value "red". I would like to use function _handleFunction_contains($arguments, $context) and use a query "//flora[contains(.,'red')]" . But the dificulty is how to pass a query "//flora[contains(.,'red')]" to function, and that is a $context? I'm new to PHP.XPath.. Thank you in advance. ktt __________________________________ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html |
From: Nigel S. <nig...@us...> - 2004-02-06 03:10:54
|
For a number of reasons, not all of which I understand, I've not been = receiving any mails from this list since July :o( Hopefully the situation is fixed now, and I'll return to being = responsive to mails from this list :o) If you have posed a question = since July, and either didn't get an answer, or didn't get a = satisfactory answer, feel free to re-post. Thanks all for your interest and support for Php.XPath :o) Cheers Nigel |
From: Gabriel T. <gth...@we...> - 2004-02-04 11:21:15
|
Hi all, I'm trying to set the encoding for my document. $options=array('XML_OPTION_TARGET_ENCODING' => "UTF-8"); $doc = new XPath(); $doc->importFromFile('request.xml'); $doc->setXmlOptions($options); $test=$doc->getNode(); print_r($test); $doc->exportToFile("NewXml1.xml"); No Errors but the latin-1 encoding from the imported file has not changed. In the end i want to create a new xml-document with utf-8 encoding. I tried: $doc = new XPath(); $doc->appendChild('', "<test></test>", true ); so far, it's working but again setting the encoding fails: $doc->setXmlOptions($options); or $doc->setXmlOption("XML_OPTION_TARGET_ENCODING", "UTF-8"); I know somehow I have to set the textParts-array of the super-root, but there has to be a nicer way to do this.. Thanks! Gabriel mailto:gth...@we... |
From: Peter R. <php...@pe...> - 2004-01-21 19:52:04
|
On Wednesday 21 Jan 2004 17:54, Gabriel Thielsch wrote: > Hello, > > I just can't figure out, how to get CDATA out of an element. > My xml file: > > <?xml version="1.0" encoding="iso-8859-1"?> > <Buyer> > <User> > <AboutMe>0</AboutMe> > <AllowPaymentEdit>1</AllowPaymentEdit> > <CIPBankAccountStored>0</CIPBankAccountStored> > <CheckoutEnabled>1</CheckoutEnabled> > <Email><![CDATA[gth...@we...]]></Email> > <RegDate>2003-12-30 15:31:20</RegDate> > <CountryCode>us</CountryCode> > <Zip>94115</Zip> > <UserId>mkgtest2</UserId> > </User> > </Buyer> > > This works fine: > > $user = $xpath->getData('/Buyer[1]/User[1]/UserId[1]/'); > $user = $xpath->getData('/Buyer[1]/User[1]/UserId[1]/text()!!'); > return is "mkgtest2". > For the element "Email" i have not found anything that returns > "gth...@we...". > I tried: > $user = $xpath->match('//Email'); > It returns Array ( [0] => /Buyer[1]/User[1]/Email[1] ) > Ok, that's fine, but when i try to use that xpath in > $user = $xpath->getData('/Buyer[1]/User[1]/Email[1]'); > or > $user = $xpath->getData('/Buyer[1]/User[1]/Email[1]/text()!!'); > i get nothing, not even an error. are you absolutely sure you get nothing? Try: <?php include('XPath.class.php'); $xml = new XPath(); $xml->importFromFile('whatever.xml'); print htmlspecialchars($xml->getData('/Buyer[1]/User[1]/Email[1]')); ?> :-) |