ID:               44973
 Comment by:       zircote at zircote dot com
 Reported By:      norbert_schuetz at bigfoot dot com
 Status:           Verified
 Bug Type:         SimpleXML related
 Operating System: Linux 2.6.18-5-686
 PHP Version:      5.2.6
 New Comment:

PHP Versions:
 * Windows / php 5.2.5 (WAMP 5)
 

 
 ************ WSDL Description of the object ***********
                        <s:complexType mixed="true" name="ProductDescription">
                                <s:annotation>
                                        <s:documentation> One of several 
possible descriptions for this
product. A
                                                product description has a type 
and a text description. The text
is in the
                                                body of this element. 
</s:documentation>
                                </s:annotation>
                                <s:attribute name="t" type="s:int">
                                        <s:annotation>
                                                <s:documentation>Product types 
are 1, 2 and 3.</s:documentation>
                                        </s:annotation>
                                </s:attribute>
                        </s:complexType>
********************************************************
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
    xmlns:xsd="http://www.w3.org/2001/XMLSchema";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
    <soap:Body>
                <descriptions>
                    <pd t="2">Sharp XL-DK255 Hi-Fi System</pd>
                    <pd t="3">Micro System 100W - CD Player</pd>
                    <pd t="1">Sharp XL-DK255 Hi-Fi System 100W - CD Player</pd>
                    <pd t="0">Stylish compact and powerful...</pd>
                </descriptions>
        </soap:Body>
</soap:Envelope>


$client = new SoapClient($wsdl);

print_r( $client->Search(SearchRequest $searchRequest));

 [descriptions] => stdClass Object ( 
         [pd] => Array ( 
         [0] => stdClassObject ( [t] => 2 ) 
         [1] => stdClass Object ( [t] => 3 ) 
         [2] => stdClass Object ( [t] => 1 ) 
         [3] => stdClass Object ( [t] => 0 ) ) 
 )


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

[2008-06-24 14:21:35] thomas dot sarlandie at backelite dot com

We have encountered the same problem.

PHP Versions:
 * Windows / php 5.2.5 (WAMP 5)
 * MacOSX php 5.2.5 (OsX 10.5.3)
 * PHP 5.1.2 (linux/ubuntu edgy)

This is our test case:

<?php
//XML string
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<a last="1214311502">
        <b>
                <c name="xxx" a="negatif">
                        <valeur type="points">444</valeur>
                        <evo type="%">1.10</evo>
                </c>
        </b>
</a>';

// XML Parsing
$object_xml = simplexml_load_string($xml);
        
echo "<pre>";
print_r($object_xml);
echo "</pre>";
?>

regards,
thomas

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

[2008-05-13 13:29:47] [EMAIL PROTECTED]

The attribute can be accessed, however toString really doesn't show
it.

print_r($xml->product[1]);

SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [order_id] => 0002
        )

    [0] => PHP book
)


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

[2008-05-12 15:44:22] norbert_schuetz at bigfoot dot com

Description:
------------
PHP Version: PHP 5.2.0-8+etch11 (CLI) from
php5-cli_5.2.0-8+etch10_i386.deb
Linux 2.6.18-5-686 #1 SMP Sun Aug 12 21:57:02 UTC 2007 i686 GNU/Linux
Simplexml support => enabled
Revision => $Revision: 1.151.2.22.2.15 $
Schema support => enabled
libexpat1_1.95.8-3.4_i386.deb

Description of problem:
For the second xml product item from the sample XML there is no
order_id-attribute in the resulting object, while both first an last
items have it.


Reproduce code:
---------------
<?php
$xmlstr=<<<EOXML
<?xml version='1.0' standalone='yes'?>
<products>
    <product order_id="0001"></product>
    <product order_id="0002">PHP book</product>
    <product order_id="0003">
        <name>PHP book</name>
    </product>
</products>
EOXML;


$xml=new SimpleXMLElement($xmlstr);
print_r($xml);
?>


Expected result:
----------------
@attributes array for second item as well

Actual result:
--------------
SimpleXMLElement Object
(
    [product] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [EMAIL PROTECTED] => Array
                        (
                            [order_id] => 0001
                        )

                )

            [1] => PHP book
            [2] => SimpleXMLElement Object
                (
                    [EMAIL PROTECTED] => Array
                        (
                            [order_id] => 0003
                        )

                    [name] => PHP book
                )

        )

)



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


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

  • #44973 [Com]: SimpleXML... zircote at zircote dot com

Reply via email to