--TEST-- Bug #40451 (addAttribute() may crash when used with non-existent child node) --FILE-- host.server.com XML; $xml = simplexml_load_string($string); $add = $xml->addChild('Host'); $add->Host->addAttribute('enable', 'true'); echo "Done\n"; ?> --EXPECTF-- Warning: SimpleXMLElement::addAttribute(): Unable to locate parent Element in %s on line %d Done