From:             rele at gmx dot de
Operating system: Windows XP SP1
PHP version:      5.1.2
PHP Bug Type:     SimpleXML related
Bug description:  SVG XML parsing looses child tags and attributes

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 bug report at http://bugs.php.net/?id=36379&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=36379&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=36379&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=36379&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=36379&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=36379&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=36379&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=36379&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=36379&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=36379&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=36379&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=36379&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=36379&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=36379&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=36379&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=36379&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=36379&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=36379&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=36379&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=36379&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=36379&r=mysqlcfg

Reply via email to