@ 2014-10-10T20:15:22Z <?php
$sxe = new SimpleXMLElement('<people xmlns:p="http://example.org/ns" xmlns:t="http://example.org/test"/>');
$xpath = new DOMXPath(($doc = dom_import_simplexml($sxe)->ownerDocument));
print_r(iterator_to_array($xpath->evaluate('/*/namespace::*')));
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.3.0 - 8.3.6 Array
(
[0] => DOMNameSpaceNode Object
(
[nodeName] => xmlns:xml
[nodeValue] => http://www.w3.org/XML/1998/namespace
[nodeType] => 18
[prefix] => xml
[localName] => xml
[namespaceURI] => http://www.w3.org/XML/1998/namespace
[isConnected] => 1
[ownerDocument] => (object value omitted)
[parentNode] => (object value omitted)
[parentElement] => (object value omitted)
)
[1] => DOMNameSpaceNode Object
(
[nodeName] => xmlns:t
[nodeValue] => http://example.org/test
[nodeType] => 18
[prefix] => t
[localName] => t
[namespaceURI] => http://example.org/test
[isConnected] => 1
[ownerDocument] => (object value omitted)
[parentNode] => (object value omitted)
[parentElement] => (object value omitted)
)
[2] => DOMNameSpaceNode Object
(
[nodeName] => xmlns:p
[nodeValue] => http://example.org/ns
[nodeType] => 18
[prefix] => p
[localName] => p
[namespaceURI] => http://example.org/ns
[isConnected] => 1
[ownerDocument] => (object value omitted)
[parentNode] => (object value omitted)
[parentElement] => (object value omitted)
)
)
Output for 5.3.11 - 5.3.29 , 5.4.1 - 5.4.45 , 5.5.24 - 5.5.35 , 5.6.8 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 Array
(
[0] => DOMNameSpaceNode Object
(
[nodeName] => xmlns:xml
[nodeValue] => http://www.w3.org/XML/1998/namespace
[nodeType] => 18
[prefix] => xml
[localName] => xml
[namespaceURI] => http://www.w3.org/XML/1998/namespace
[ownerDocument] => (object value omitted)
[parentNode] => (object value omitted)
)
[1] => DOMNameSpaceNode Object
(
[nodeName] => xmlns:t
[nodeValue] => http://example.org/test
[nodeType] => 18
[prefix] => t
[localName] => t
[namespaceURI] => http://example.org/test
[ownerDocument] => (object value omitted)
[parentNode] => (object value omitted)
)
[2] => DOMNameSpaceNode Object
(
[nodeName] => xmlns:p
[nodeValue] => http://example.org/ns
[nodeType] => 18
[prefix] => p
[localName] => p
[namespaceURI] => http://example.org/ns
[ownerDocument] => (object value omitted)
[parentNode] => (object value omitted)
)
)
Output for 5.3.7 - 5.3.10 , 5.4.0 Array
(
[0] => DOMNameSpaceNode Object
(
)
[1] => DOMNameSpaceNode Object
(
)
[2] => DOMNameSpaceNode Object
(
)
)
Output for 5.3.6 Array
(
[23980432] => DOMNameSpaceNode Object
(
)
)
Output for 5.3.5 Array
(
[19425680] => DOMNameSpaceNode Object
(
)
)
Output for 5.3.4 Array
(
[24361360] => DOMNameSpaceNode Object
(
)
)
Output for 5.3.3 Array
(
[37534096] => DOMNameSpaceNode Object
(
)
)
Output for 5.2.0 - 5.2.17 , 5.3.0 - 5.3.2 Catchable fatal error: Argument 1 passed to iterator_to_array() must implement interface Traversable, instance of DOMNodeList given in /in/b8M6B on line 4
Process exited with code 255 . Output for 5.1.0 - 5.1.6 Warning: iterator_to_array() expects parameter 1 to be Traversable, object given in /in/b8M6B on line 4
Output for 5.0.0 - 5.0.5 Fatal error: Call to undefined function iterator_to_array() in /in/b8M6B on line 4
Process exited with code 255 . Output for 4.4.2 - 4.4.9 Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/b8M6B on line 3
Process exited with code 255 . Output for 4.3.0 - 4.3.1 , 4.3.5 - 4.3.11 , 4.4.0 - 4.4.1 Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/b8M6B on line 3
Process exited with code 255 . Output for 4.3.2 - 4.3.4 Parse error: parse error in /in/b8M6B on line 3
Process exited with code 255 . preferences:dark mode live preview
238.66 ms | 401 KiB | 341 Q