ID: 44547 Updated by: [EMAIL PROTECTED] Reported By: s_nutchanat at hotmail dot com -Status: Open +Status: Bogus Bug Type: DOM XML related Operating System: Linux PHP Version: 5.2.5 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php data converted to string is concat of all text nodes of all the data nodes. Bad query Previous Comments: ------------------------------------------------------------------------ [2008-03-27 11:43:10] s_nutchanat at hotmail dot com 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 this bug report at http://bugs.php.net/?id=44547&edit=1
