Thread: idw - continued
Brought to you by:
bs_php,
nigelswinson
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: Nigel S. <nig...@us...> - 2002-01-18 00:02:51
|
(I know this thread is kinda old, but it's been in my inbox all month...) > 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. That's cos you ask hard questions :o) > 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? A good point. Sounds annoying. :o( I think the plan is to support different levels of error reporting, so when you build the class, you set an option to say what kind of errors you want. So what you'd do then is say that you don't want errors if the node doesn't exist and you'd be happy, and if you want it to complain, you can leave the errors on. So yeah, we are aiming for this too :o) 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. <php...@pe...> - 2002-01-19 14:50:57
|
On Friday 18 Jan 2002 12:02 am, Nigel Swinson wrote: > > I think the plan is to support different levels of error reporting, so when > you build the class, you set an option to say what kind of errors you want. > So what you'd do then is say that you don't want errors if the node doesn't > exist and you'd be happy, and if you want it to complain, you can leave the > errors on. So yeah, we are aiming for this too :o) sounds good to me. Don't want to be a pest, but . . . got any idea of an ETA? At the moment, I'm still running the original phpxml script, which is not the most rapid . . . |
From: Nigel S. <nig...@us...> - 2002-01-19 15:10:06
|
> > I think the plan is to support different levels of error reporting, so when > > you build the class, you set an option to say what kind of errors you want. > > So what you'd do then is say that you don't want errors if the node doesn't > > exist and you'd be happy, and if you want it to complain, you can leave the > > errors on. So yeah, we are aiming for this too :o) > > sounds good to me. > > Don't want to be a pest, but . . . got any idea of an ETA? At the moment, I'm > still running the original phpxml script, which is not the most rapid . . . Think the plan is something as follows: - Finish the test harness V2.3 - February/March - Tidy and clean up whitespace issues V2.4 - April/May - Enhance and optimize V2.5- Summer But then you know how these things go. The brakes have been on fairly hard over Christmas as I was building my new hardware and software. Sam and Dan have both been very busy too. Under no circumstances should you "plan" round these release dates. I'm just giving you an idea as to what the targets are in my mind. :o) Nigel |
From: Peter R. <php...@pe...> - 2002-02-21 14:01:19
|
Going back to this thread, I've been looking into this a bit further and I find that getAttributes works as I would like whereas getData doesn't. So if I do getAttributes( ... specific attribute that doesn't exist) it returns false, so I can do if ($var = getAttributes) do whatever with $var; which is what I want. Bizarrely, if I do the same with getData, i.e. for a path to an attribute that doesn't exist, it fails with an error. So rather than different levels of reporting, I think all I really need is for getData (and for that matter nodeName, which has the same problem) to behave like getAttributes and return false if the node does not exist. At the moment, given a xml file with variable structure, evaluate seems to be the only way of getting, for example, a list of child nodes or finding if a particular node exists. Evaluate, though, seems to really slow things down. I've just converted one such file from phpxml to phpxpath, thinking that it would speed things up, and it's actually substantially slower - I think because of all the evaluates that I have to include to check whether child nodes exist or not. On Friday 18 Jan 2002 12:02 am, Nigel Swinson wrote: > > > > 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? > > A good point. Sounds annoying. :o( > > I think the plan is to support different levels of error reporting, so when > you build the class, you set an option to say what kind of errors you want. > So what you'd do then is say that you don't want errors if the node doesn't > exist and you'd be happy, and if you want it to complain, you can leave the > errors on. So yeah, we are aiming for this too :o) |