Bug #62639 [Com]: XML structure broken

From: Date: Wed, 09 Apr 2014 17:29:35 +0000
Subject: Bug #62639 [Com]: XML structure broken
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185158@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62639&edit=1

 ID:                 62639
 Comment by:         knyttl at goout dot cz
 Reported by:        alexshock at yandex dot ru
 Summary:            XML structure broken
 Status:             Assigned
 Type:               Bug
 Package:            SimpleXML related
 Operating System:   debian 6.0.5
 PHP Version:        5.4.5
 Assigned To:        acurioso
 Block user comment: N
 Private report:     N

 New Comment:

Thanks for your replies.


Previous Comments:
------------------------------------------------------------------------
[2014-04-09 10:42:26] pavel at icewarp dot com

So any update? this issue is hanging here for almost two years ? Will you fix it ?

------------------------------------------------------------------------
[2014-03-29 20:47:54] knyttl at goout dot cz

Why you develop new features, when the old ones are unusable?

------------------------------------------------------------------------
[2014-02-11 11:33:16] electroglyph at gmail dot com

???

------------------------------------------------------------------------
[2013-12-29 20:34:00] knyttl at goout dot cz

Is there something happening with this issue? It is now in stable debian and others :/

------------------------------------------------------------------------
[2013-08-16 01:59:10] sergey at shymko dot net

The following workaround seems to fix both dumping and type casting:

<?php

class SimpleXMLElement_CloneFix extends SimpleXMLElement
{
    public function xpath($path)
    {
        $result = parent::xpath($path) ?: array();
        foreach ($result as $node) {
            $this->_fixNode($node);
        }
        return $result;
    }

    protected function _fixNode(SimpleXMLElement $node)
    {
        if (!$node && (string)$node) {
            $dom = dom_import_simplexml($node);
            $dom->parentNode->replaceChild(clone $dom, $dom);
        }
    }
}

Unfortunately, the same approach does not work for children() method, because of mysterious nature
of its returned value.
Despite returned object manifests itself as an instance of SimpleXMLElement, it does not behave as
such.
For instance, it is incompatible with dom_import_simplexml().
So, what kind of SimpleXMLElement is that?

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=62639


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


Thread (21 messages)

« previous php.bugs (#185158) next »