From:             s_nutchanat at hotmail dot com
Operating system: Linux
PHP version:      5.2.5
PHP Bug Type:     DOM XML related
Bug description:  Problem with starts-with in XPath

Description:
------------
I would like to query my XML file with XPath using starts-with.
This is an example of my XML file:
<?xml version="1.0" encoding="utf-8"?>
<graphml>
  <graph id="G" edgedefault="directed">
    <node id="4">
      <data key="label">name</data>
      <data key="value">Alanine</data>
      <data key="node_path">moldb.molecule.name</data>
    </node>
  </graph>
</graphml>

I want to query to the node having the "node_path" attribute beginning by
"moldb". But this didn't work. After trying many cases, I think it came
from the XML structure that has more than one "data" nodes. If there is
only one "data" node, it worked.

Reproduce code:
---------------
Here is my code:
$doc = new DomDocument(); // document to be explored
if (!$doc->load("ex.xml"))
{
        return; // invalid file
}
$xpath = new DOMXPath($doc); // to search for the nodes we want
$data = 'moldb';
$query = "/graphml/graph/node[starts-with(data,'$data')]";
$query = "/graphml/graph/[EMAIL PROTECTED]'node_path'] and
starts-with(data,'$data')]";
$entries = $xpath->evaluate($query);
echo $entries->length."\n";

Expected result:
----------------
When executing this script, it should print:
1

Actual result:
--------------
The obtained result is:
0

-- 
Edit bug report at http://bugs.php.net/?id=44547&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44547&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44547&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44547&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44547&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44547&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44547&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44547&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44547&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44547&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44547&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44547&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44547&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44547&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44547&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44547&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44547&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44547&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44547&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44547&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44547&r=mysqlcfg

Reply via email to