PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.php > Limits to XPath implementaiton in PHP5
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Limits to XPath implementaiton in PHP5

Réponse
 
LinkBack Outils de la discussion
Vieux 22/10/2007, 22h58   #1
Weston
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Limits to XPath implementaiton in PHP5

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?

  Réponse avec citation
Vieux 22/10/2007, 23h37   #2
Jeremy
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Limits to XPath implementaiton in PHP5

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
  Réponse avec citation
Vieux 25/10/2007, 23h24   #3
Weston
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Limits to XPath implementaiton in PHP5

On Oct 22, 3:37 pm, Jeremy <jer...@pinacol.com> wrote:
> 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.






  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 09h32.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09240 seconds with 11 queries