Poking around with XPath using SimpleXML, it looks like there are at
least a few reasonably common XPath operators and predicates that
aren't supported. I'd like to check my observations against other
people's experience, and find out if I'm missing something.
Here's what it looks like to me in PHP 5.2.0:
* the count() predicate seems to fail quietly (no error or warning,
you just receive a false value from the xpath method rather than an
array)
* the "|" (union) operator seems to also fail quietly by returning an
empty array
* the "union" operator seems to cause an error
* the "intersect" operator also causes an error (and needless to say,
with | and count() not working, using something like the Kaysian
technique to get the intersection won't work)
Does this accurately capture the current state of things?
If so, are the bulk of developers simply not using these features, or
are they instead writing around the missing features in PHP rather
than trying to get XPath to do the work?
Or is there a better option? 2 2727
Weston wrote:
Poking around with XPath using SimpleXML, it looks like there are at
least a few reasonably common XPath operators and predicates that
aren't supported. I'd like to check my observations against other
people's experience, and find out if I'm missing something.
Here's what it looks like to me in PHP 5.2.0:
* the count() predicate seems to fail quietly (no error or warning,
you just receive a false value from the xpath method rather than an
array)
* the "|" (union) operator seems to also fail quietly by returning an
empty array
* the "union" operator seems to cause an error
* the "intersect" operator also causes an error (and needless to say,
with | and count() not working, using something like the Kaysian
technique to get the intersection won't work)
Does this accurately capture the current state of things?
If so, are the bulk of developers simply not using these features, or
are they instead writing around the missing features in PHP rather
than trying to get XPath to do the work?
Or is there a better option?
AFAIK, the various PHP API's (SimpleXML, DOM) use libxml as a backend,
without much logic in between. So if the XPath operators are supported
by libxml, they ought to be supported by PHP. If they're not supported
by libxml, that would really surprise me.
That said, try using the DOM API instead of SimpleXML and see if you
have better results. Then, try peeking into the libxml error stack
directly using the libxml functions: http://us.php.net/manual/en/ref.libxml.php
Jeremy
On Oct 22, 3:37 pm, Jeremy <jer...@pinacol.comwrote:
That said, try using the DOM API instead of SimpleXML and see if you
have better results.
There are indeed some different results. Here's a basic rundown:
count() predicate: succesful under DOM, fails quietly under SimpleXML
"|" (union) operator: succesful under DOM, not sure under SimpleXML
"union" operator: fails with error under both
"intersect" operator: fails with error under both
kaysian intersection technique: succesful under DOM, fails under
SimpleXML
>Then, try peeking into the libxml error stack
directly using the libxml functions:
http://us.php.net/manual/en/ref.libxml.php
I'll have to poke at that further, but at this point it does look like
both APIs can't simply be handing off to libxml. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Chris |
last post by:
Hi all,
I have recently started working with the new XML functionality in
PHP5, but I am running into a few problems. Specifically, I am using
an Xpath query to try and pull out the data in...
|
by: Börni |
last post by:
Hi,
I couldnt find an answer to my question in the php manual, so i try it
here.
Basically i just want to know if the following is possible.
Suppose you have this xml file:
<root>
<news...
|
by: Joshua Beall |
last post by:
Hi All,
I have a task that should be very simple but I'm running into trouble. All
I want to do is query a document using XPath, and save the resulting XML in
a string. Here's that I am trying...
|
by: Zac |
last post by:
I've been googling all day and I haven't seen anyone else having this
problem, so I thought I'd check to see if I'm unique or I should be
expecting this behavior.
I've recompiled and reinstalled...
|
by: Rutger Claes |
last post by:
Hello,
In an XSL stylesheet, that I apply using an XSLTProcessor() in PHP5, I would
like to use the function fn:month-from-dateTime( ). I found this function
at:...
|
by: bdinmstig |
last post by:
I refined my attempt a little further, and the following code does
seem to work, however it has 2 major problems:
1. Very limited support for XPath features
Basic paths are supported for...
|
by: laks |
last post by:
Hi
I have the following xsl stmt.
<xsl:for-each select="JOB_POSTINGS/JOB_POSTING
\">
<xsl:sort select="JOB_TITLE" order="ascending"/>
This works fine when I use it.
But when using multiple...
|
by: sugoi.sama |
last post by:
hi,
i'm having a hellish adventure with PHP5 i hope someone just can help
me out on this... i'm desperate
All i want to do, is to get the index of the returned elements, so i
can acess them...
|
by: McKirahan |
last post by:
I am working in two environments neither configuration of
which I can change; one's my Web host the other a client.
My Web host requires the use of the ".php5" extension
to use PHP v5.1.4; where...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |