phpxpath-users Mailing List for Php.XPath (Page 13)
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: 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...> - 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: Matt M. <car...@do...> - 2001-12-20 01:21:50
|
On Wed, Dec 19, 2001 at 11:06:22AM +0000, Paul / USH wrote: > I have some xml data like the following: (where you see [ and ] these > are really < and > so they don't get confused with html tags :) > > [root] > [en] > some text with [b] bold [b] inside it > [/en] > [root] > > What I want it to pull out ALL the contents of the [en] node > including all the bold tags etc. getData only gets : some text with > inside it (looses the stuff in the bold tags) getDataParts returns an > array with > [0]=>some text with > [1]=> inside it > substringData returns the same as getData > > How can I get all the tags properly within the [en] node. > I've tried doing a exportAsHTML on the [en] node and substring the > [en] and [/en] but that is a horrible way to do it. If you intend [b] bold [/b] to be an HTML tag, rather than an XML tag, you'll need to store it as <b> bold </b> As it is now, the XML parser will treat [b] bold [/b] as an XML tag, which is why it doesn't come out when you fetch [en]'s contents. > Also, I've seen talk of the ampersand problem being fixed in the > exportAsXML - so I'm trying to get the latest version from anonymous > CVS - but don't know what the module names are to get. Trying to list > the module names with -c results in nothing? You can browse the CVS repository with ViewCVS at http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/phpxpath/ HTH, Matt |
From: Paul / U. <pa...@tr...> - 2001-12-19 11:16:16
|
I have some xml data like the following: (where you see [ and ] these are really < and > so they don't get confused with html tags :) [root] [en] some text with [b] bold [b] inside it [/en] [root] What I want it to pull out ALL the contents of the [en] node including all the bold tags etc. getData only gets : some text with inside it (looses the stuff in the bold tags) getDataParts returns an array with [0]=>some text with [1]=> inside it substringData returns the same as getData How can I get all the tags properly within the [en] node. I've tried doing a exportAsHTML on the [en] node and substring the [en] and [/en] but that is a horrible way to do it. Also, I've seen talk of the ampersand problem being fixed in the exportAsXML - so I'm trying to get the latest version from anonymous CVS - but don't know what the module names are to get. Trying to list the module names with -c results in nothing? Thanks for your time and help Paul Lawton |
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-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: Nigel S. <nig...@us...> - 2001-12-11 21:53:11
|
> sorry about that last one....been a long day :( > > i've encountered a bug in 2.1b which i reported (#491220). seems that > if you have the following xml: > > <item><data>0</data><data>1</data></item> > > importing then exporting results in > > <item><data/><data>1</data></item> > > basically losing the '0' Thanks, have made a fix to the development version. =========================== For the most recent version of Php.XPath, and an archive of this list visit: http://www.sourceforge.net/projects/phpxpath |
From: Nigel S. <nig...@us...> - 2001-12-11 21:13:43
|
> on Saturday Dec 08 at 03.45 PM, Nigel Swinson wrote: > > Neat! I like it :o) > > > > > on Friday Dec 07 at 05.04 PM, Peter Robins wrote: > > > > On Friday 07 Dec 2001 4:22 pm, jm3 wrote: > > > > > > http://jm3.net/misc/php-xpath-quickstart/ > > > > > > with any luck this document could help other newbies just beginning to > > > wet their feet with php.xpath. > > great, thanks! i submitted it to the doc manager page on sourceforge. Cool, ta. Have approved and a link to jm's quickstart is now available from the phpxpath homepage :o) =========================== For the most recent version of Php.XPath, and an archive of this list visit: http://www.sourceforge.net/projects/phpxpath |
From: <chr...@ma...> - 2001-12-11 01:03:00
|
sorry about that last one....been a long day :( i've encountered a bug in 2.1b which i reported (#491220). seems that if you have the following xml: <item><data>0</data><data>1</data></item> importing then exporting results in <item><data/><data>1</data></item> basically losing the '0' i've fixed the problem on 2.1b (unfortunately i am behind corp firewall and can't checkout cvs version) here is the diff for XPath.class.php: 1676c1676,1677 < if (empty($theNode['text'])) { --- > if(!isset($theNode['text'])) { > //if (empty($theNode['text'])) { 1681c1682,1683 < $useShortEnd = (!$hasChildren && empty($mergedText)); --- > $useShortEnd = (!$hasChildren && !isset($mergedText)); > //$useShortEnd = (!$hasChildren && empty($mergedText)); 1821c1823,1824 < if (trim($this->xmlTxtBuffer) OR trim($text)) { --- > if (trim($this->xmlTxtBuffer) != '' OR trim($text) != '') { > // if (trim($this->xmlTxtBuffer) OR trim($text)) { Christopher Hall Software Engineer III Sprint - OSS/ASE/TDG 813-237-4276 800-724-3329/382-0658 |
From: <chr...@ma...> - 2001-12-11 00:58:28
|
Christopher Hall Software Engineer III Sprint - OSS/ASE/TDG 813-237-4276 800-724-3329/382-0658 |
From: john m. I. <jm...@jm...> - 2001-12-08 03:55:22
|
on Friday Dec 07 at 05.04 PM, Peter Robins wrote: > On Friday 07 Dec 2001 4:22 pm, you wrote: > > I had much the same thoughts myself. Here's a simple sample I wrote, <snip /> thank you kindly! saved my life, aka. lots of time fiddling around to figure stuff out. much obliged. in answer to my own question, i made a concise five-step php.xpath "getting started" guide with a small working demo and src, visible at: http://jm3.net/misc/php-xpath-quickstart/ with any luck this document could help other newbies just beginning to wet their feet with php.xpath. -- jm3 / john manoogian III / bad...@jm... / www.jm3.net |
From: Peter R. <php...@pe...> - 2001-12-07 17:05:36
|
On Friday 07 Dec 2001 4:22 pm, you wrote: > > also, a short example php file showing basic php.xpath usage would be > extremely helpful. the class documentation is nice, but not so helpful > to a beginning user who doesn't necessarily know in advance what > methods might be useful. i downloaded the pxpxmldb source to have > something else to look at, but just a simple "here's a new xpath > object, here's how we select a node and print it out, done." would go a > long way. i'll try and write one and post it, maybe that could also be > bundled with the download as a resource for new users. I had much the same thoughts myself. Here's a simple sample I wrote, first evaluating the first occurrence, then doing the same thing using a specific attribute. You can remove the comment on the print_r to see what evaluate/match creates (easier to read as plain text rather than html). |
From: Nigel S. <nig...@us...> - 2001-12-07 16:27:47
|
> <snip> possibly something should get added to > the readme about, it's a bit disconcerting to see all those errors at > first. > > also, a short example php file showing basic php.xpath usage would be > extremely helpful. <snip> All in due time folks :o) I'd like to see this stuff too, but we are trying to spend the time on 2.2 which will hopefully bring us out of "beta", then we can enhance speed and produce more FAQ and examples stuff. Nigel |
From: john m. I. <li...@jm...> - 2001-12-07 16:21:32
|
on Friday Dec 07 at 11.31 AM, Peter Robins wrote: > not seen this error, but line 163 is in a deprecated function. Do you get the > same msg using the preferred appendData, which uses different parameters? that's kinda the same question that sam blum asked me. the funny part is, i'm not /using/ any of the functions yet, all i did was a one-line test page that just require()'s the class.php file. i added the "php_flag allow_call_time_pass_reference on" directive to my .htacess file, which made the php compiler shut up about the deprecation warnings. possibly something should get added to the readme about, it's a bit disconcerting to see all those errors at first. also, a short example php file showing basic php.xpath usage would be extremely helpful. the class documentation is nice, but not so helpful to a beginning user who doesn't necessarily know in advance what methods might be useful. i downloaded the pxpxmldb source to have something else to look at, but just a simple "here's a new xpath object, here's how we select a node and print it out, done." would go a long way. i'll try and write one and post it, maybe that could also be bundled with the download as a resource for new users. regards, -- jm3 / john manoogian III / bad...@jm... / www.jm3.net |
From: Peter R. <php...@pe...> - 2001-12-07 11:35:27
|
not seen this error, but line 163 is in a deprecated function. Do you get the same msg using the preferred appendData, which uses different parameters? On Thursday 06 Dec 2001 5:25 am, you wrote: > hi, i use xpath all the time, but i'm a little new to php. > i'm using the latest version of php.xpath [2.1 (beta)], > and whether i include() it or require() it, i get copious [well, ten] > > errors of the following sort: > > 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 [runtime function name](). 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 /root/path/XPath_V2/XPath.class.php on line 163 > > there was no INSTALL or README in the top level of the src directory; > am i missing a step, or does this look like php version-mismatch? > > thanks in advance, > > -- jm3 / john manoogian III / bad...@jm... / www.jm3.net > > _______________________________________________ > Phpxpath-users mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phpxpath-users |
From: Peter R. <ph...@pe...> - 2001-12-06 14:15:51
|
can't say I've been inundated with solutions to my previous posting :-(, but it's actually easy to fix w/o recompiling PHP as Dan suggests. Just escape the underscores in eregs, i.e. on lines 1990 and 2778. Having fixed that, I now have a different problem. I have an xml file with large numbers of child (+ grandchild ...) nodes which may or may not be present. My old phpxml script did an evaluate for the top level and then get_Contents for any children it needed; if a child didn't exist, phpxml simply set the variable to null. phpxpath, however, seems to throw an error and refuse to continue if you try and getData or getDataParts for a child or attribute that doesn't exist. If I have to do a match/evaluate for each of these nodes before getData, not only is that a lot of extra work but I'll probably have to rewrite the logic. Can phpxpath be changed to be like phpxml and simply set the variable to null if getData doesn't find the node? |
From: <li...@jm...> - 2001-12-06 05:23:48
|
hi, i use xpath all the time, but i'm a little new to php. i'm using the latest version of php.xpath [2.1 (beta)], and whether i include() it or require() it, i get copious [well, ten] errors of the following sort: > 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 [runtime function name](). 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 /root/path/XPath_V2/XPath.class.php on line 163 there was no INSTALL or README in the top level of the src directory; am i missing a step, or does this look like php version-mismatch? thanks in advance, -- jm3 / john manoogian III / bad...@jm... / www.jm3.net |
From: Dietrich A. <die...@ga...> - 2001-12-03 01:40:30
|
i'm just writing out pseudocode off the top of my head, cause i haven't used the newer versions of the class :) there is (was?) a method that returned the root node (if there isn't, there should be). if you already know your root node, just cut that part out, and pass your root node in. it was just a convenience thang anyway. and i wasn't passing 2 nodes to appendChild, i was assuming you could call it like so: appendChild($node,$newNodeName,$newNodeValue). looks like you must call appendData() to set element content, so just cut off the ",$v" from that part. > -----Original Message----- > From: Girish Nath [mailto:gi...@bt...] > Sent: Sunday, December 02, 2001 8:27 PM > To: Dietrich Ayala; php...@li... > Subject: Re: Multi-dimension Array to XML ? > > > Hi > > I'm trying to modify this code but running into some problems. > > I've noticed your using a getRoot() function as well as passing what seem > like multiple nodenames to appendChild() > > This doesn't seem to be in v2.1 on sourceforge.net, are you using some kind > of dev version? > > Thanks > > > Girish > > > > > ----- Original Message ----- > From: "Dietrich Ayala" <die...@ga...> > To: "Girish Nath" <gi...@bt...>; > <php...@li...> > Sent: Monday, December 03, 2001 12:10 AM > Subject: RE: Multi-dimension Array to XML ? > > > > you could do something like this (again, pseudocode): > > > > function recursiveArraytoxml(&$myXML,$array,$contexNode=false){ > > // if no context node passed, set root node as context > > if(!$contextNode){ > > $contextNode = $myXML->getRoot(); > > } > > // loop thru array, creating nodes > > foreach($request as $k => $v){ > > // recurse if value is an array > > if(is_array($v)){ > > $newNode = $myXML->appendChild($node, $k); > > recursiveArraytoxml($myXML,$newNode,$v); > > } else { > > $newNode = $myXML->appendChild($node, $k, $v); > > $myXML->appendData($newNode, $v); > > } > > } > > } > > > > > -----Original Message----- > > > From: php...@li... > > > [mailto:php...@li...]On Behalf Of Girish > > > Nath > > > Sent: Sunday, December 02, 2001 5:50 PM > > > To: php...@li... > > > Cc: Dietrich Ayala > > > Subject: Re: Multi-dimension Array to XML ? > > > > > > > > > Hi > > > > > > Thanks for your code, i've modified it to insert data from my array too, > but > > > i need some advice regarding flexibilty. > > > > > > Currently it will deal with an array such as below with no problem. > > > > > > $request["mission"]["dest"] = "France"; > > > $request["mission"]["date"] = "22/07/2001"; > > > > > > > > > But if i add one more level for example : > > > > > > > > > $request["contact"]["email"]["work"] = "j....@mi..."; > > > $request["contact"]["email"]["home"] = "j....@ao..."; > > > > > > It can't handle it, i need to go down atleast one more level, but would > also > > > like to make it future-proof just in-case the project specs get modified > > > later. > > > > > > Thanks for your help. > > > > > > > > > Girish > > > > > > > > > $root = "/request[1]"; > > > > > > foreach($request as $k => $v){ > > > > > > if(is_array($v)){ > > > $newNode = $myXML->appendChild($root, $k); > > > > > > foreach($v as $a => $b){ > > > $myXML->appendChild($newNode,$a, $b); > > > $myXML->appendData($newNode . "/" . $a, $b); > > > } > > > > > > } > > > else { > > > $newNode = $myXML->appendChild($root, $k, $v); > > > $myXML->appendData($newNode, $v); > > > } > > > > > > } > > > > > > print $myXML->exportAsXml(); > > > > > > > > > > > > > > > ----- Original Message ----- > > > From: "Dietrich Ayala" <die...@ga...> > > > To: "Girish Nath" <gi...@bt...> > > > Sent: Saturday, December 01, 2001 10:14 PM > > > Subject: RE: Multi-dimension Array to XML ? > > > > > > > > > > here's an example of how to do it, but i can't remember if i got the > > > phpxml method names/args correct. check the class docs. > > > > but the basics should be there: > > > > > > > > $root = getRoot($phpxml); > > > > foreach($request as $k => $v){ > > > > if(is_array($v){ > > > > $newNode = $phpxml->addChild($root,$k); > > > > foreach($v as $a => $b){ > > > > $phpxml->addChild($newNode,$a,$b); > > > > } > > > > } else { > > > > $newNode = $phpxml->addChild($root,$k,$v); > > > > } > > > > } > > > > > > > > then use the xml export method. > > > > > > > > > > > > > -----Original Message----- > > > > > From: php...@li... > > > > > [mailto:php...@li...]On Behalf Of > Girish > > > > > Nath > > > > > Sent: Saturday, December 01, 2001 2:12 AM > > > > > To: php...@li... > > > > > Subject: Multi-dimension Array to XML ? > > > > > > > > > > > > > > > Hi > > > > > > > > > > Has anyone got any ideas how to take a multi-dimension array and > output > > > it > > > > > as XML ? > > > > > > > > > > The array for example : > > > > > > > > > > $request["agent"] = "James Bond"; > > > > > $request["codename"] = "007"; > > > > > $request["expenses"] = "100000000"; > > > > > > > > > > $request["mission"]["dest"] = "France"; > > > > > $request["mission"]["date"] = "22/07/2001"; > > > > > > > > > > $request["contact"]["email"]["work"] = "j....@mi..."; > > > > > $request["contact"]["email"]["home"] = "j....@ao..."; > > > > > > > > > > Thank you :) > > > > > > > > > > > > > > > Girish > > > > > > > > > > > > > > > _______________________________________________ > > > > > Phpxpath-users mailing list > > > > > Php...@li... > > > > > https://lists.sourceforge.net/lists/listinfo/phpxpath-users > > > > > > > > > > > > > > _______________________________________________ > > > Phpxpath-users mailing list > > > Php...@li... > > > https://lists.sourceforge.net/lists/listinfo/phpxpath-users > > > > > > > _______________________________________________ > > Phpxpath-users mailing list > > Php...@li... > > https://lists.sourceforge.net/lists/listinfo/phpxpath-users > > > |
From: Girish N. <gi...@bt...> - 2001-12-03 01:29:39
|
Hi I'm trying to modify this code but running into some problems. I've noticed your using a getRoot() function as well as passing what seem like multiple nodenames to appendChild() This doesn't seem to be in v2.1 on sourceforge.net, are you using some kind of dev version? Thanks Girish ----- Original Message ----- From: "Dietrich Ayala" <die...@ga...> To: "Girish Nath" <gi...@bt...>; <php...@li...> Sent: Monday, December 03, 2001 12:10 AM Subject: RE: Multi-dimension Array to XML ? > you could do something like this (again, pseudocode): > > function recursiveArraytoxml(&$myXML,$array,$contexNode=false){ > // if no context node passed, set root node as context > if(!$contextNode){ > $contextNode = $myXML->getRoot(); > } > // loop thru array, creating nodes > foreach($request as $k => $v){ > // recurse if value is an array > if(is_array($v)){ > $newNode = $myXML->appendChild($node, $k); > recursiveArraytoxml($myXML,$newNode,$v); > } else { > $newNode = $myXML->appendChild($node, $k, $v); > $myXML->appendData($newNode, $v); > } > } > } > > > -----Original Message----- > > From: php...@li... > > [mailto:php...@li...]On Behalf Of Girish > > Nath > > Sent: Sunday, December 02, 2001 5:50 PM > > To: php...@li... > > Cc: Dietrich Ayala > > Subject: Re: Multi-dimension Array to XML ? > > > > > > Hi > > > > Thanks for your code, i've modified it to insert data from my array too, but > > i need some advice regarding flexibilty. > > > > Currently it will deal with an array such as below with no problem. > > > > $request["mission"]["dest"] = "France"; > > $request["mission"]["date"] = "22/07/2001"; > > > > > > But if i add one more level for example : > > > > > > $request["contact"]["email"]["work"] = "j....@mi..."; > > $request["contact"]["email"]["home"] = "j....@ao..."; > > > > It can't handle it, i need to go down atleast one more level, but would also > > like to make it future-proof just in-case the project specs get modified > > later. > > > > Thanks for your help. > > > > > > Girish > > > > > > $root = "/request[1]"; > > > > foreach($request as $k => $v){ > > > > if(is_array($v)){ > > $newNode = $myXML->appendChild($root, $k); > > > > foreach($v as $a => $b){ > > $myXML->appendChild($newNode,$a, $b); > > $myXML->appendData($newNode . "/" . $a, $b); > > } > > > > } > > else { > > $newNode = $myXML->appendChild($root, $k, $v); > > $myXML->appendData($newNode, $v); > > } > > > > } > > > > print $myXML->exportAsXml(); > > > > > > > > > > ----- Original Message ----- > > From: "Dietrich Ayala" <die...@ga...> > > To: "Girish Nath" <gi...@bt...> > > Sent: Saturday, December 01, 2001 10:14 PM > > Subject: RE: Multi-dimension Array to XML ? > > > > > > > here's an example of how to do it, but i can't remember if i got the > > phpxml method names/args correct. check the class docs. > > > but the basics should be there: > > > > > > $root = getRoot($phpxml); > > > foreach($request as $k => $v){ > > > if(is_array($v){ > > > $newNode = $phpxml->addChild($root,$k); > > > foreach($v as $a => $b){ > > > $phpxml->addChild($newNode,$a,$b); > > > } > > > } else { > > > $newNode = $phpxml->addChild($root,$k,$v); > > > } > > > } > > > > > > then use the xml export method. > > > > > > > > > > -----Original Message----- > > > > From: php...@li... > > > > [mailto:php...@li...]On Behalf Of Girish > > > > Nath > > > > Sent: Saturday, December 01, 2001 2:12 AM > > > > To: php...@li... > > > > Subject: Multi-dimension Array to XML ? > > > > > > > > > > > > Hi > > > > > > > > Has anyone got any ideas how to take a multi-dimension array and output > > it > > > > as XML ? > > > > > > > > The array for example : > > > > > > > > $request["agent"] = "James Bond"; > > > > $request["codename"] = "007"; > > > > $request["expenses"] = "100000000"; > > > > > > > > $request["mission"]["dest"] = "France"; > > > > $request["mission"]["date"] = "22/07/2001"; > > > > > > > > $request["contact"]["email"]["work"] = "j....@mi..."; > > > > $request["contact"]["email"]["home"] = "j....@ao..."; > > > > > > > > Thank you :) > > > > > > > > > > > > Girish > > > > > > > > > > > > _______________________________________________ > > > > Phpxpath-users mailing list > > > > Php...@li... > > > > https://lists.sourceforge.net/lists/listinfo/phpxpath-users > > > > > > > > > > _______________________________________________ > > Phpxpath-users mailing list > > Php...@li... > > https://lists.sourceforge.net/lists/listinfo/phpxpath-users > > > > _______________________________________________ > Phpxpath-users mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phpxpath-users |
From: Dietrich A. <die...@ga...> - 2001-12-03 00:04:19
|
you could do something like this (again, pseudocode): function recursiveArraytoxml(&$myXML,$array,$contexNode=false){ // if no context node passed, set root node as context if(!$contextNode){ $contextNode = $myXML->getRoot(); } // loop thru array, creating nodes foreach($request as $k => $v){ // recurse if value is an array if(is_array($v)){ $newNode = $myXML->appendChild($node, $k); recursiveArraytoxml($myXML,$newNode,$v); } else { $newNode = $myXML->appendChild($node, $k, $v); $myXML->appendData($newNode, $v); } } } > -----Original Message----- > From: php...@li... > [mailto:php...@li...]On Behalf Of Girish > Nath > Sent: Sunday, December 02, 2001 5:50 PM > To: php...@li... > Cc: Dietrich Ayala > Subject: Re: Multi-dimension Array to XML ? > > > Hi > > Thanks for your code, i've modified it to insert data from my array too, but > i need some advice regarding flexibilty. > > Currently it will deal with an array such as below with no problem. > > $request["mission"]["dest"] = "France"; > $request["mission"]["date"] = "22/07/2001"; > > > But if i add one more level for example : > > > $request["contact"]["email"]["work"] = "j....@mi..."; > $request["contact"]["email"]["home"] = "j....@ao..."; > > It can't handle it, i need to go down atleast one more level, but would also > like to make it future-proof just in-case the project specs get modified > later. > > Thanks for your help. > > > Girish > > > $root = "/request[1]"; > > foreach($request as $k => $v){ > > if(is_array($v)){ > $newNode = $myXML->appendChild($root, $k); > > foreach($v as $a => $b){ > $myXML->appendChild($newNode,$a, $b); > $myXML->appendData($newNode . "/" . $a, $b); > } > > } > else { > $newNode = $myXML->appendChild($root, $k, $v); > $myXML->appendData($newNode, $v); > } > > } > > print $myXML->exportAsXml(); > > > > > ----- Original Message ----- > From: "Dietrich Ayala" <die...@ga...> > To: "Girish Nath" <gi...@bt...> > Sent: Saturday, December 01, 2001 10:14 PM > Subject: RE: Multi-dimension Array to XML ? > > > > here's an example of how to do it, but i can't remember if i got the > phpxml method names/args correct. check the class docs. > > but the basics should be there: > > > > $root = getRoot($phpxml); > > foreach($request as $k => $v){ > > if(is_array($v){ > > $newNode = $phpxml->addChild($root,$k); > > foreach($v as $a => $b){ > > $phpxml->addChild($newNode,$a,$b); > > } > > } else { > > $newNode = $phpxml->addChild($root,$k,$v); > > } > > } > > > > then use the xml export method. > > > > > > > -----Original Message----- > > > From: php...@li... > > > [mailto:php...@li...]On Behalf Of Girish > > > Nath > > > Sent: Saturday, December 01, 2001 2:12 AM > > > To: php...@li... > > > Subject: Multi-dimension Array to XML ? > > > > > > > > > Hi > > > > > > Has anyone got any ideas how to take a multi-dimension array and output > it > > > as XML ? > > > > > > The array for example : > > > > > > $request["agent"] = "James Bond"; > > > $request["codename"] = "007"; > > > $request["expenses"] = "100000000"; > > > > > > $request["mission"]["dest"] = "France"; > > > $request["mission"]["date"] = "22/07/2001"; > > > > > > $request["contact"]["email"]["work"] = "j....@mi..."; > > > $request["contact"]["email"]["home"] = "j....@ao..."; > > > > > > Thank you :) > > > > > > > > > Girish > > > > > > > > > _______________________________________________ > > > Phpxpath-users mailing list > > > Php...@li... > > > https://lists.sourceforge.net/lists/listinfo/phpxpath-users > > > > > > _______________________________________________ > Phpxpath-users mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phpxpath-users > |
From: Girish N. <gi...@bt...> - 2001-12-02 22:54:16
|
Hi Thanks for your code, i've modified it to insert data from my array too, but i need some advice regarding flexibilty. Currently it will deal with an array such as below with no problem. $request["mission"]["dest"] = "France"; $request["mission"]["date"] = "22/07/2001"; But if i add one more level for example : $request["contact"]["email"]["work"] = "j....@mi..."; $request["contact"]["email"]["home"] = "j....@ao..."; It can't handle it, i need to go down atleast one more level, but would also like to make it future-proof just in-case the project specs get modified later. Thanks for your help. Girish $root = "/request[1]"; foreach($request as $k => $v){ if(is_array($v)){ $newNode = $myXML->appendChild($root, $k); foreach($v as $a => $b){ $myXML->appendChild($newNode,$a, $b); $myXML->appendData($newNode . "/" . $a, $b); } } else { $newNode = $myXML->appendChild($root, $k, $v); $myXML->appendData($newNode, $v); } } print $myXML->exportAsXml(); ----- Original Message ----- From: "Dietrich Ayala" <die...@ga...> To: "Girish Nath" <gi...@bt...> Sent: Saturday, December 01, 2001 10:14 PM Subject: RE: Multi-dimension Array to XML ? > here's an example of how to do it, but i can't remember if i got the phpxml method names/args correct. check the class docs. > but the basics should be there: > > $root = getRoot($phpxml); > foreach($request as $k => $v){ > if(is_array($v){ > $newNode = $phpxml->addChild($root,$k); > foreach($v as $a => $b){ > $phpxml->addChild($newNode,$a,$b); > } > } else { > $newNode = $phpxml->addChild($root,$k,$v); > } > } > > then use the xml export method. > > > > -----Original Message----- > > From: php...@li... > > [mailto:php...@li...]On Behalf Of Girish > > Nath > > Sent: Saturday, December 01, 2001 2:12 AM > > To: php...@li... > > Subject: Multi-dimension Array to XML ? > > > > > > Hi > > > > Has anyone got any ideas how to take a multi-dimension array and output it > > as XML ? > > > > The array for example : > > > > $request["agent"] = "James Bond"; > > $request["codename"] = "007"; > > $request["expenses"] = "100000000"; > > > > $request["mission"]["dest"] = "France"; > > $request["mission"]["date"] = "22/07/2001"; > > > > $request["contact"]["email"]["work"] = "j....@mi..."; > > $request["contact"]["email"]["home"] = "j....@ao..."; > > > > Thank you :) > > > > > > Girish > > > > > > _______________________________________________ > > Phpxpath-users mailing list > > Php...@li... > > https://lists.sourceforge.net/lists/listinfo/phpxpath-users > > |
From: Girish N. <gi...@bt...> - 2001-12-01 07:14:11
|
Hi Has anyone got any ideas how to take a multi-dimension array and output it as XML ? The array for example : $request["agent"] = "James Bond"; $request["codename"] = "007"; $request["expenses"] = "100000000"; $request["mission"]["dest"] = "France"; $request["mission"]["date"] = "22/07/2001"; $request["contact"]["email"]["work"] = "j....@mi..."; $request["contact"]["email"]["home"] = "j....@ao..."; Thank you :) Girish |
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-11-25 00:45:07
|
> Hello, > > I have problem with ExportAsXML. > > Source document: > > <xmp> > <html> > <body> > <b>first</b><i>second></i> > </body> > </html> > </xmp> > > exported by exportasxml looks: > > <xmp> > <html> > <body> > <b>first</b> > <i>second></i> > </body> > </html> > </xmp> > > For (x)html it is serious inteference... > > In my opinion including spaces and \n chars before tag (when document is > exported) should be optional. > > Greetings, > Lukasz Keler The Php.XPath development team are in complete agreement. In the future you'll find three modes of operation that you can select between. 1) Keep whitespace exactly as it was in the input file (the developent version currently does this) 2) "Pretty print" the xml adding \n after close tags (2.1 does this) 3) Trim all unnecessary whitespace. You'd select between the different modes using a SetOption() call after or at construction. Thanks for your interest. Nigel =========================== For the most recent version of Php.XPath, and an archive of this list visit: http://www.sourceforge.net/projects/phpxpath |
From: Peter R. <ph...@pe...> - 2001-11-07 13:02:19
|
I installed phpxml for a project several months ago, and have had little time since. I'm now trying to update to the new version, but can't get it to work. I have just tried the useCases as provided out of the box and get the same problems: whatever I enter in the XPath expression box (except //*), I get error msgs similar to the following: ---------------------- Configuration Array ( [XmlFile] => government.xml [XPath] => /government[1] [Value] => [Action] => Search ) Searching Warning: Invalid range end in XPath.class.php on line 1990 Warning: Invalid range end in XPath.class.php on line 2778 XPath error in XPath.class.php:2788 While parsing the XPath expression "/government[1]" an empty and therefore invalid node-test has been found. ------------------- I see Dan has reported the 'invalid range end' in the bugs on sourceforge. I have had this msg in other scripts since installing php 4.0.6, and fixed it in them by removing the _ in the ereg list. I tried doing the same in phpxpath - this gets rid of the warnings, but doesn't fix the problem! What's going on? Btw, when I first used the useCases, I got 'Error, function test not written yet' until it dawned on me I'm supposed to press 'Search' not enter. Would suggest search should be default. |