bug43221.phpt 622 B

123456789101112131415161718
  1. --TEST--
  2. Bug #43221 (SimpleXML adding default namespace in addAttribute)
  3. --EXTENSIONS--
  4. simplexml
  5. --FILE--
  6. <?php
  7. $xml = simplexml_load_string('<?xml version="1.0" encoding="utf-8"?><root />');
  8. $n = $xml->addChild("node", "value");
  9. $n->addAttribute("a", "b");
  10. $n->addAttribute("c", "d", "http://bar.com");
  11. $n->addAttribute("foo:e", "f", "http://bar.com");
  12. print_r($xml->asXml());
  13. ?>
  14. --EXPECTF--
  15. Warning: SimpleXMLElement::addAttribute(): Attribute requires prefix for namespace in %sbug43221.php on line %d
  16. <?xml version="1.0" encoding="utf-8"?>
  17. <root><node xmlns:foo="http://bar.com" a="b" foo:e="f">value</node></root>