profile11.phpt 830 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. SimpleXML [profile]: Accessing two elements with the same name, but different namespaces
  3. --EXTENSIONS--
  4. simplexml
  5. --FILE--
  6. <?php
  7. error_reporting(E_ALL & ~E_NOTICE);
  8. $root = simplexml_load_string('<?xml version="1.0"?>
  9. <root xmlns:reserved="reserved-ns" xmlns:special="special-ns">
  10. <reserved:child>Hello</reserved:child>
  11. <special:child>World</special:child>
  12. </root>
  13. ');
  14. var_dump($root->children('reserved-ns')->child);
  15. var_dump($root->children('special-ns')->child);
  16. var_dump((string)$root->children('reserved-ns')->child);
  17. var_dump((string)$root->children('special-ns')->child);
  18. var_dump($root->child);
  19. ?>
  20. --EXPECTF--
  21. object(SimpleXMLElement)#%d (1) {
  22. [0]=>
  23. string(5) "Hello"
  24. }
  25. object(SimpleXMLElement)#%d (1) {
  26. [0]=>
  27. string(5) "World"
  28. }
  29. string(5) "Hello"
  30. string(5) "World"
  31. object(SimpleXMLElement)#%d (0) {
  32. }