#42325 [Opn->Bgs]: xmlns parsing issues
ID: 42325
Updated by: chregu@php.net
Reported By: cpriest at warpmail dot net
-Status: Open
+Status: Bogus
Bug Type: SimpleXML related
Operating System: Windows
PHP Version: 5.2.4RC2
New Comment:
You have to register default namespaces with
http://ch2.php.net/manual/en/function.simplexml-element-
registerXPathNamespace.php
Previous Comments:
------------------------------------------------------------------------
[2007-08-17 04:08:56] cpriest at warpmail dot net
Description:
------------
SimpleXML is having some difficulty in parsing XML which contains a
default xmlns entry.
Reproduce code:
---------------
<?
header('Content-Type: text/plain');
$ResponseBody = '<?xml version="1.0" encoding="UTF-8"?>
<result xmlns="https://zzz.com/webservices"
xmlns:xsd="https://www.w3.org/2001/XMLSchema"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance">Test</result>';
$objXML = new SimpleXMLElement($ResponseBody);
$tMatches = $objXML->xpath('/result');
print_r((string)$tMatches[0]);
?>
Expected result:
----------------
Expect print_r() to print "Test"
Actual result:
--------------
$tMatches is an empty array()
If you change the xmlns="https://zzz.com/webservices" to
xmlns:zzz="https://zzz.com/webservices"
(add a namespace sub-string), it
works fine.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42325&edit=1
Thread (8 messages)