From: Operating system: Ubuntu PHP version: 5.3SVN-2011-02-22 (SVN) Package: XML related Bug Type: Bug Bug description:simplexml_load_file wont load the xml from LOC which has a ':'
Description: ------------ <?php error_reporting(E_ALL); ini_set("display_errors", 1); $request='http://z3950.loc.gov:7090/voyager?version=1.1&operation=searchRetrieve&query=dinosaur&startRecord=2&maximumRecords=5'; $string = file_get_contents($request); // echo $string; $string = str_replace(":", "_", $string); // echo $string; $sxe = new SimpleXMLElement($string); if (!$sxe) { echo "Failed loading XML\n"; foreach(libxml_get_errors() as $error) { echo "\t", $error->message; } } //var_dump ($sxe); print_r ($sxe); print $sxe[10]; ?> Test script: --------------- <?php error_reporting(E_ALL); ini_set("display_errors", 1); $request='http://z3950.loc.gov:7090/voyager?version=1.1&operation=searchRetrieve&query=dinosaur&startRecord=2&maximumRecords=5'; $string = file_get_contents($request); // echo $string; $sxe = new SimpleXMLElement($string); if (!$sxe) { echo "Failed loading XML\n"; foreach(libxml_get_errors() as $error) { echo "\t", $error->message; } } //var_dump ($sxe); print_r ($sxe); print $sxe[10]; ?> Expected result: ---------------- Warning: SimpleXMLElement::__construct(): namespace warning : xmlns: URI http_//www.loc.gov/MARC21/slim is not absolute in /home/scott/public_html/xml5.php on line 12 Warning: SimpleXMLElement::__construct(): Array ( [xmlns_zs] => http_//www.loc.gov/zing/srw/ ) [zs_version] => 1.1 [zs_numberOfRecords] => 2144 [zs_records] => SimpleXMLElement Object ( [zs_record] => Array ( [0] => SimpleXMLElement Object ( [zs_recordSchema] => info_srw/schema/1/marcxml-v1.1 [zs_recordPacking] => xml [zs_recordData] => SimpleXMLElement Object ( [record] => SimpleXMLElement Object ( [leader] => 01026ngm a22002773a 4500 [controlfield] => Array ( [0] => 16429180 [1] => 20100823131409.0 [2] => vffcjaho| [3] => 100823s2010 xxu060 mleng ) [datafield] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [tag] => 906 [ind1] => [ind2] => ) [subfield] => Array ( [0] => 0 [1] => cbc [2] => orignew [3] => u [4] => ncip [5] => 20 [6] => y-movingim ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [tag] => 955 [ind1] => [ind2] => ) [subfield] => qm12 2010-08-23 ) [2] => SimpleXMLElement Object ( [@attributes] => Array ( [tag] => 010 [ind1] => [ind2] => ) [subfield] => 2010608899 ) [3] => SimpleXMLElement Object ( [@attributes] => Array ( [tag] => 017 [ind1] => [ind2] => ) [subfield] => Array ( [0] => PA0001684303 [1] => U.S. Copyright Office ) ) [4] => SimpleXMLElement Object ( [@attributes] => Array ( [tag] => 040 [ind1] => [ind2] => ) [subfield] => Array ( [0] => DLC [1] => DLC [2] => amim ) ) [5] => SimpleXMLElement Object ( [@attributes] => Array ( [tag] => 050 [ind1] => 0 [ind2] => 0 ) [subfield] => VBU 4599 (viewing copy) ) [6] => SimpleXMLElement Object ( [@attributes] => Array ( [tag] => 245 [ind1] => 0 [ind2] => 0 ) [subfield] => Array ( [0] => 30 Rock. [1] => Emmanuelle goes to Dinosaur Land. ) ) [7] => SimpleXMLElement Object ( [@attributes] => Array ( [tag] => 246 [ind1] => 3 [ind2] => 0 ) [subfield] => Emmanuelle goes to Dinosaur Land ) [8] => SimpleXMLElement Object ( [@attributes] => Array ( [tag] => 246 [ind1] => 3 [ind2] => ) [subfield] => Array ( [0] => Thirty rock. [1] => Emmanuelle goes to Dinosaur Land ) ) [9] => SimpleXMLElement Object ( [@attributes] => Array ( [tag] => 257 [ind1] => [ind2] => ) [subfield] => United States. ) [10] => SimpleXMLElement Object ( [@attributes] => Array ( [tag] => 260 [ind1] => [ind2] => ) Actual result: -------------- Nothing, simplexml does not load at all due to the ':' in the xml file -- Edit bug report at http://bugs.php.net/bug.php?id=54072&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54072&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54072&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54072&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=54072&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54072&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=54072&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=54072&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=54072&r=needscript Try newer version: http://bugs.php.net/fix.php?id=54072&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=54072&r=support Expected behavior: http://bugs.php.net/fix.php?id=54072&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=54072&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=54072&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=54072&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54072&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=54072&r=dst IIS Stability: http://bugs.php.net/fix.php?id=54072&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=54072&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=54072&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=54072&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=54072&r=mysqlcfg