php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37622 Odd DOMXPath->query behaviour
Submitted: 2006-05-29 08:47 UTC Modified: 2006-05-29 10:09 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: nickm at tbms dot ru Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.1.4 OS: Windows XP SP2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nickm at tbms dot ru
New email:
PHP Version: OS:

 

 [2006-05-29 08:47 UTC] nickm at tbms dot ru
Description:
------------
I've tried to execute the 
"/gesmes:Envelope/:Cube/:Cube/:Cube[@currency='USD']" XPath instruction
via the
DOMXPath->query method
on the
"http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml"

but I got neither parse error nor the DOMNodeList. The result is simply empty.

I validated my istruction here:
"http://www.activsoftware.com/xml/xpath/"
Аnd it get exactly what I want from the XML document.

Reproduce code:
---------------
$from = "USD";
$result = $xPath->query("/gesmes:Envelope/:Cube/:Cube/:Cube[@currency='" . strtoupper($from) . "']");
//$result is EMPTY!


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-29 08:59 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.


 [2006-05-29 09:09 UTC] nickm at tbms dot ru
Here is the code:
<?
$document = new DOMDocument("1.0", "utf-8");
$document->load("http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml");
$xPath = new DOMXPath($document);
$result = $xPath->query("/gesmes:Envelope/:Cube/:Cube/:Cube[@currency='USD']");
//Oops! $result is somehow empty
if ($result->length > 0) {
  print "OK!";
} else {
  print "ERROR!";
}
?>
 [2006-05-29 09:30 UTC] tony2001@php.net
Warning: DOMXPath::query(): Invalid expression in /tmp/3.php on line 5

Warning: DOMXPath::query(): Invalid expression in /tmp/3.php on line 5
bool(false)

Did you try to enable display_errors ?
 [2006-05-29 10:00 UTC] nickm at tbms dot ru
I ve localized the code from my framework and it gives errors now. Seems to me that the problem is in the QUERY. But on thing is still confusing me why the QUERY works via the

http://www.activsoftware.com/xml/xpath/ processor and some others?
 [2006-05-29 10:09 UTC] tony2001@php.net
.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 15 03:01:33 2024 UTC