1--TEST--
2Interoperability with SimpleXML
3--EXTENSIONS--
4dom
5simplexml
6--FILE--
7<?php
8
9$sxe = simplexml_load_string('<container xmlns="urn:a">foo</container>');
10
11$element = Dom\import_simplexml($sxe);
12var_dump($element->attributes);
13echo $element->ownerDocument->saveXml($element), "\n";
14
15$element->appendChild($element->ownerDocument->createElementNS('urn:a', 'child'));
16echo $element->ownerDocument->saveXml($element), "\n";
17
18$sxe->addChild('name', 'value');
19echo $element->ownerDocument->saveXml($element), "\n";
20
21// This should fail because it has been imported already above in modern DOM
22try {
23    dom_import_simplexml($sxe);
24} catch (TypeError $e) {
25    echo $e->getMessage(), "\n";
26}
27
28// Import again and compare
29var_dump(Dom\import_simplexml($sxe) === $element);
30
31?>
32--EXPECT--
33object(Dom\NamedNodeMap)#3 (1) {
34  ["length"]=>
35  int(1)
36}
37<container xmlns="urn:a">foo</container>
38<container xmlns="urn:a">foo<child/></container>
39<container xmlns="urn:a">foo<child/><name>value</name></container>
40dom_import_simplexml(): Argument #1 ($node) must not be already imported as a Dom\Node
41bool(true)
42