php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50951 SimpleXml xpath does not return proper xpath query
Submitted: 2010-02-07 05:45 UTC Modified: 2013-02-18 00:34 UTC
From: arashaga at gmail dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.3.1 OS: xp
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: arashaga at gmail dot com
New email:
PHP Version: OS:

 

 [2010-02-07 05:45 UTC] arashaga at gmail dot com
Description:
------------
in the example below I get the xpath query result in Xpath qury tools like Xpath spy but when it's run in PHP I don't get anything.




it shoud output the storename but it doesn't.

Reproduce code:
---------------
//xml file (partially)
<Item>
<ItemID>341396747871</ItemID>
−
<ViewItemURLForNaturalSearch>
http://product.half.ebay.com/GMAT-Quantitative-Review-Paperback-2005_W0QQprZ48636818QQtgZvidetailsQQitemZ341396747871
</ViewItemURLForNaturalSearch>
<Quantity>1</Quantity>
−
<Seller>
<FeedbackScore>32</FeedbackScore>
<PositiveFeedbackPercent>100.0</PositiveFeedbackPercent>
</Seller>
<CurrentPrice currencyID="USD">1.98</CurrentPrice>
−
<Storefront>
−
<StoreURL>
http://shops.half.ebay.com/rogerlee14_W0QQsellerZrogerlee14
</StoreURL>
<StoreName>rogerlee14</StoreName>
</Storefront>
<Country>US</Country>
<HalfItemCondition>BrandNew</HalfItemCondition>
−
<SellerComments>
Brand new, never used.  No markings at all.  Ships fast!
</SellerComments>
</Item>

the query is

//CurrentPrice[.=1.98]/parent::Item/Storefront/StoreName

Expected result:
----------------
rogerlee14

Actual result:
--------------
boolean(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-07 09:37 UTC] jani@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 the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2010-02-08 21:59 UTC] arashaga at gmail dot com
<?php

/*please use the xml feed that I have provided as an example instead 
of the ebay.xml*/
$xml = simplexml_load_file('ebay.xml');

 $xml-
>registerXpathNamespace('ebay','urn:ebay:apis:eBLBaseComponents');

 $resp = $xml-
>xpath("//ebay:CurrentPrice[.=1.98]/parent::Item/Storefront/StoreName"
);
 
for($i=0;$i < count($resp)/2; $i++ )
{
	
foreach($resp[$i] as  $key => $value)
{
	//echo "['".$key."']=".$value."<br>";
	echo "[$key]= $value<br>";
	
}
}
?>
 [2010-02-08 22:35 UTC] arashaga at gmail dot com
Actually instead of that whole "for and foreach" block we can use 
var_dump($rest);

and it will return bool(false).
 [2010-02-13 21:50 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2010-02-21 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2010-04-25 20:07 UTC] felipe@php.net
-Status: No Feedback +Status: Feedback
 [2010-04-25 20:07 UTC] felipe@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Oct 07 12:03:43 2022 UTC