ID: 30861 Updated by: [EMAIL PROTECTED] Reported By: jason at amp-design dot net -Status: Open +Status: Wont fix Bug Type: *XML functions Operating System: Win2003 / CentOS / MacOS X PHP Version: 5.0.2 New Comment:
Doesn't work by design... And I don't think it will be addressed in a future version of PHP Previous Comments: ------------------------------------------------------------------------ [2004-11-22 14:36:45] jason at amp-design dot net Description: ------------ This relates to bug ID 29092 that I posted, however this makes it hard to extend use extended classes for DOMnodes and move them about from document to document without loosing the object type. If there is any other solution or work about, I would be grateful. Is this something that is not fixable, or will it be addressed in future versions of PHP? DOMNode::cloneNode also suffers this as well, from what I remember. Reproduce code: --------------- <?php class Bar extends DOMElement { public $foo = 'FooBar happens'; } /* Load of nonsense XML */ $xml = '<root><foo><bar><foo2 /><foo2 />Foo bar Foo bar Foo bar<foo2 /></bar><bar2 /></foo></root>'; // Yea I know i should use the DOMimplementation factory method here. $doc = new DOMDocument(); $doc->loadXML($xml); $root = $doc->documentElement; /* Append new FooBar into main document */ $BarObj = new Bar('EatMoreFoo'); $root->appendChild($BarObj); /* Assign FooBar */ $BarObj->foo = 'FooBar Happens to change'; $BarObj->setAttribute('id', 'dfdf'); /* make another document */ $doc2 = new DOMDocument(); /* import our other document's root. Note here the upcasting to DOMelement happens */ $root2 = $doc2->importNode($root, true); $doc2->appendChild($root2); /* PooPoo happens here. * Node is copied and thus no PHP reference to the node, * hence upcasting of object occur */ $x_path_cack = new DOMXPath($doc2); $list_of_cack = $x_path_cack->query('//EatMoreFoo'); print_R($list_of_cack->item(0)); // Should echo FooBar Object() ?> Expected result: ---------------- FooFar Object ( ) Actual result: -------------- DOMElement Object ( ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30861&edit=1