ID:               37035
 User updated by:  mir at datanom dot net
 Reported By:      mir at datanom dot net
 Status:           Open
 Bug Type:         SimpleXML related
 Operating System: GNU/Linux
 PHP Version:      5.1.2
 New Comment:

Forgot to provide a simple example:

<?php
//    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"; 
//    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
//    xmlns:xsd="http://www.w3.org/2001/XMLSchema";
$xml = <<<_XML
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope>
<soap:Body> 
<businessList 
    generic="2.0" operator="ms.com" truncated="false" 
    xmlns="urn:uddi-org:api_v2"> 
<businessInfos> 
    <businessInfo businessKey="c13cc7b2-642d-41d0-b2dd-7bb531a18997">
        <name xml:lang="en">Microsoft DRMS Dev</name> 
        <serviceInfos>
            <serviceInfo 
                serviceKey="6166f8b2-436d-4001-9f68-f37ff8b47ea3" 
                businessKey="c13cc7b2-642d-41d0-b2dd-7bb531a18997">
                <name xml:lang="en">Certification</name>
            </serviceInfo> 
        </serviceInfos> 
    </businessInfo>
</businessInfos>
</businessList>
</soap:Body> 
</soap:Envelope>
_XML;

$document = simplexml_load_string($xml);
if (!$document)
    echo "Failed to parse document!\n";
else
    print_r($document);
?>

This example works. Adding the 3 uncommented namespace declarations to
the root element will make simplexml_load_string return false.


Previous Comments:
------------------------------------------------------------------------

[2006-04-10 23:13:13] mir at datanom dot net

Description:
------------
Given this xml document simplexml_load_string and simplexml_load_file
returns false

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
<soap:Body> 
<businessList 
        generic="2.0" operator="ms.com" truncated="false" 
        xmlns="urn:uddi-org:api_v2"> 
<businessInfos> 
<businessInfo           businessKey="c13cc7b2-642d-41d0-b2dd-7bb531a18997">
<name xml:lang="en">Microsoft DRMS Dev</name> 
<serviceInfos>
<serviceInfo 
serviceKey="6166f8b2-436d-4001-9f68-f37ff8b47ea3" 
businessKey="c13cc7b2-642d-41d0-b2dd-7bb531a18997">
<name xml:lang="en">Certification</name>
</serviceInfo> 
</serviceInfos> 
</businessInfo>
</businessInfos>
</businessList>
</soap:Body> 
</soap:Envelope>

If I erase namespace references from the root element a valid simpleXML
object is returned:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope>
<soap:Body> 
<businessList 
        generic="2.0" operator="ms.com" truncated="false" 
        xmlns="urn:uddi-org:api_v2"> 
<businessInfos> 
<businessInfo           businessKey="c13cc7b2-642d-41d0-b2dd-7bb531a18997">
<name xml:lang="en">Microsoft DRMS Dev</name> 
<serviceInfos>
<serviceInfo 
serviceKey="6166f8b2-436d-4001-9f68-f37ff8b47ea3" 
businessKey="c13cc7b2-642d-41d0-b2dd-7bb531a18997">
<name xml:lang="en">Certification</name>
</serviceInfo> 
</serviceInfos> 
</businessInfo>
</businessInfos>
</businessList>
</soap:Body> 
</soap:Envelope>

Reproduce code:
---------------
class xmlParser
{
        private $document;

        public function __construct($xml)
        {
        $this->document =                             
simplexml_load_string((string)$xml);
        if (!$this->document)
                throw new xmlParserException("The XML document is not 
well-formed:
\n" . $xml);
        }
}

Expected result:
----------------
A SimpleXML Object



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=37035&edit=1

Reply via email to