Terence <tk.lists@fastmail.fm> shaped the electrons to say:[color=blue]
>I assumed you were asking why you got the exception about trying to use
>a method on a non-object.[/color]
That was one symptom - why goes get_elements_by_tagname() work if you
start from the docroot or the immediate parent, but no where in
between? Perhaps this is fixed in a later version of PHP - from the
docs it sounds like it *should* recurse the structure no matter where
you start from.
[color=blue]
>The fact that xpath doesn't work with get_elements_by_tagnam() is[/color]
It does appear to work some of the time, and one of the comments left
in the online PHP documentation illustrates using XPath:
http://us2.php.net/manual/en/functio...by-tagname.php
That, and other examples I found when looking for sample code, seemed
to indicate XPath was valid. It seemed to make sense as that also fit
with the behavior of other languages.
But this evening I found this:
http://bugs.php.net/bug.php?id=26205
From one of the comments:
---
chregu@php.net
you are using xpath-expressions and not simple element-names. This may
had worked with older php versions, but the internal code was changed
later.
If you want to use something like "timeopen/year" then use the
appropriate xpath methods (see manual..)
---
So it sounds like the right thing to do is switch to straight tagnames
where possible, and use the xpath functions where it isn't.
[color=blue]
>implementing only features of the lowest common denominator. If you are
>writing a cross-platform (ie. multi language) framework, you will always[/color]
It is part of a payment system - the framework exists in different
languages because it is the piece merchant can integrate with their
backend. So we provide it in whatever language the merchant is using
for their site. Before I joined the company a year ago it was
basically a Windows shop so it was ASP and CF, I did the Perl and PHP
implementations. JSP is on the roadmap. But I readily admit I'm
still learning PHP - I tend to implement any new features in Perl
first since that's my primary language, and then port it to PHP. For
the most part that's worked rather well, the language structures are
close enough that a lot of the 'porting' can be done with emacs
regexps. Looks like this is one of the 'gotchas' though - it looked
like 'get_elements_by_tagname' was a drop in replacement for
'findnodes', but that no long seems to be the case.
[color=blue]
>have these limitations. While PHP5 will be using libxml2, I don't know
>if this means it will support XPath in get_elements_by_tagnam(). The
>behaviour is non-standard.[/color]
Based on what I found tonight, it sounds like the move is away from
allowing XPath in the PHP functions - except for the xpath_eval, etc,
family.
I've probably made my share of newbie errors in the PHP port - I know
I used 'isset' in a number of places and some of them I caught and
made 'is_object', but some are probably still off. Like most things,
it was done with the "we need it yesterday" mandate, so I didn't have
a lot of time to refresh my PHP knowledge. I picked up O'Reilly's
Programming PHP, the PHP.net documentation, and hit the ground
running. ;-)
-MZ, RHCE #806199299900541, ex-CISSP #3762
--
<URL:mailto:megazoneatmegazone.org> Gweep, Discordian, Author, Engineer, me.
"A little nonsense now and then, is relished by the wisest men" 508-755-4098
<URL:http://www.megazone.org/> <URL:http://www.eyrie-productions.com/> Eris