ID:               36379
 User updated by:  rele at gmx dot de
 Reported By:      rele at gmx dot de
-Status:           No Feedback
+Status:           Open
 Bug Type:         SimpleXML related
 Operating System: Windows XP SP1
-PHP Version:      5.1.2
+PHP Version:      5.1.4
 New Comment:

Description:
------------
Maybe it will be clearer if I use type casting.
As you can see in the result output, there is no array index 0 in each
parent which should store the text value of the first child, like there
are for all childs.
Especially not for parent 1a "ParentText " and 1c " ".

The attributes are fine, either by direct access $parent['style'] or by
using $parent->attributes().

But $parent[0] is always NULL.


Reproduce code:
---------------
$test_simplexml_errors_svg = <<<EOD
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd";[
  <!ENTITY E1 'font-size:7pt'>
]>
<svg id="svg_output" version="1.1" xmlns="http://www.w3.org/2000/svg";
viewBox="-2 -7 1561 708">
  <text id="1a" style="&E1;" x="300" y="100">ParentText <tspan id="2a"
dy="12" x="310">ChildText1</tspan><tspan id="3a" dy="12" x="350">
</tspan></text>
  <text id="1b" style="&E1;" x="400" y="200"><tspan id="2b" dy="12"
x="410">ChildText1</tspan><tspan id="3b" dy="12" x="450">
</tspan></text>
  <text id="1c" style="&E1;" x="500" y="300"> <tspan id="2c" dy="12"
x="510">ChildText1</tspan><tspan id="3c" dy="12"
x="550">ChildText2</tspan></text>
</svg>
EOD;

$simplexml = simplexml_load_string($test_simplexml_errors_svg);
foreach($simplexml as &$parent) {
  echo 'parent ', $parent->getName(), ' ', $parent['id'], ' = "',
(string) $parent, '"', "\n";
  print_r($parent);
  foreach($parent as $child) {
    echo ' child ', $child->getName(), ' ', $child['id'], ' = "',
(string) $child, '"', "\n";
    print_r($child);
  }
}

Actual result:
--------------
parent text 1a = "ParentText "
SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [id] => 1a
            [style] => font-size:7pt
            [x] => 300
            [y] => 100
        )
    [tspan] => Array
        (
            [0] => ChildText1
            [1] => SimpleXMLElement Object
                (
                    [EMAIL PROTECTED] => Array
                        (
                            [id] => 3a
                            [dy] => 12
                            [x] => 350
                        )
                    [0] => 
                )
        )
)
 child tspan 2a = "ChildText1"
SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [id] => 2a
            [dy] => 12
            [x] => 310
        )
    [0] => ChildText1
)
 child tspan 3a = "
"
SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [id] => 3a
            [dy] => 12
            [x] => 350
        )
    [0] => 
)
parent text 1b = ""
SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [id] => 1b
            [style] => font-size:7pt
            [x] => 400
            [y] => 200
        )
    [tspan] => Array
        (
            [0] => ChildText1
            [1] => SimpleXMLElement Object
                (
                    [EMAIL PROTECTED] => Array
                        (
                            [id] => 3b
                            [dy] => 12
                            [x] => 450
                        )
                    [0] => 
                )
        )
)
 child tspan 2b = "ChildText1"
SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [id] => 2b
            [dy] => 12
            [x] => 410
        )
    [0] => ChildText1
)
 child tspan 3b = "
"
SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [id] => 3b
            [dy] => 12
            [x] => 450
        )
    [0] => 
)
parent text 1c = " "
SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [id] => 1c
            [style] => font-size:7pt
            [x] => 500
            [y] => 300
        )
    [tspan] => Array
        (
            [0] => ChildText1
            [1] => ChildText2
        )
)
 child tspan 2c = "ChildText1"
SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [id] => 2c
            [dy] => 12
            [x] => 510
        )
    [0] => ChildText1
)
 child tspan 3c = "ChildText2"
SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [id] => 3c
            [dy] => 12
            [x] => 550
        )
    [0] => ChildText2
)


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

[2006-05-09 11:17:55] mithu_pehelwan at yahoo dot com

Fuck you man in the whole u mother fucker

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

[2006-02-23 01:00:04] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

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

[2006-02-15 06:55:52] [EMAIL PROTECTED]

print_r (and var_dump) isn't a reliable method for checking, 
what's "inside" a simplexml object.

Please check with an iterator, if there's really something 
missing and provide a reproducable script.

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

[2006-02-13 15:24:18] rele at gmx dot de

Description:
------------
I want to parse SVG XML code with SimpleXML, but under certain
circumstances the parsed SimpleXMLElements do not contain either
attributes or child tags.

Reproduce code:
---------------
$test_simplexml_errors_svg = <<<EOD
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd";[
  <!ENTITY E1 'font-size:7pt'>
]>
<svg id="svg_output" version="1.1" xmlns="http://www.w3.org/2000/svg";
viewBox="-2 -7 1561 708">
  <text id="1a" style="&E1;" x="300" y="100">ParentText <tspan id="2a"
dy="12" x="310">ChildText1</tspan><tspan id="3a" dy="12" x="350">
</tspan></text>
  <text id="1b" style="&E1;" x="400" y="200"><tspan id="2b" dy="12"
x="410">ChildText1</tspan><tspan id="3b" dy="12" x="450">
</tspan></text>
  <text id="1c" style="&E1;" x="500" y="300"><tspan id="2c" dy="12"
x="510">ChildText1</tspan><tspan id="3c" dy="12"
x="550">ChildText2</tspan></text>
</svg>
EOD;
print_r(simplexml_load_string($test_simplexml_errors_svg));


Expected result:
----------------
SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [id] => svg_output
            [version] => 1.1
            [viewBox] => -2 -7 1561 708
        )

    [text] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [EMAIL PROTECTED] => Array
                        (
                            [id] => 1a
                            [style] => font-size:7pt
                            [x] => 300
                            [y] => 100
                        )

                    [0] => ParentText

                )

            [1] => SimpleXMLElement Object
                (
                    [EMAIL PROTECTED] => Array
                        (
                            [id] => 1b
                            [style] => font-size:7pt
                            [x] => 400
                            [y] => 200
                        )

                    [tspan] => Array
                        (
                            [0] => SimpleXMLElement Object
                                (
                                    [EMAIL PROTECTED] => Array
                                        (
                                            [id] => 2b
                                            [dy] => 12
                                            [x] => 410
                                        )

                                    [0] => ChildText1
                                )

                            [1] => SimpleXMLElement Object
                                (
                                    [EMAIL PROTECTED] => Array
                                        (
                                            [id] => 3b
                                            [dy] => 12
                                            [x] => 450
                                        )

                                    [0] =>
                                )

                        )

                )

            [2] => SimpleXMLElement Object
                (
                    [EMAIL PROTECTED] => Array
                        (
                            [id] => 1c
                            [style] => font-size:7pt
                            [x] => 500
                            [y] => 300
                        )

                    [tspan] => Array
                        (
                            [0] => SimpleXMLElement Object
                                (
                                    [EMAIL PROTECTED] => Array
                                        (
                                            [id] => 2c
                                            [dy] => 12
                                            [x] => 510
                                        )

                                    [0] => ChildText1
                                )

                            [1] => SimpleXMLElement Object
                                (
                                    [EMAIL PROTECTED] => Array
                                        (
                                            [id] => 3c
                                            [dy] => 12
                                            [x] => 550
                                        )

                                    [0] => ChildText2
                                )
                        )

                )

        )

)

Actual result:
--------------
SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [id] => svg_output
            [version] => 1.1
            [viewBox] => -2 -7 1561 708
        )

    [text] => Array
        (
            [0] => ParentText 
            [1] => SimpleXMLElement Object
                (
                    [EMAIL PROTECTED] => Array
                        (
                            [id] => 1b
                            [style] => font-size:7pt
                            [x] => 400
                            [y] => 200
                        )

                    [tspan] => Array
                        (
                            [0] => ChildText1
                            [1] => SimpleXMLElement Object
                                (
                                    [EMAIL PROTECTED] => Array
                                        (
                                            [id] => 3b
                                            [dy] => 12
                                            [x] => 450
                                        )

                                    [0] =>  
                                )

                        )

                )

            [2] => SimpleXMLElement Object
                (
                    [EMAIL PROTECTED] => Array
                        (
                            [id] => 1c
                            [style] => font-size:7pt
                            [x] => 500
                            [y] => 300
                        )

                    [tspan] => Array
                        (
                            [0] => ChildText1
                            [1] => ChildText2
                        )

                )

        )

)


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


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

Reply via email to