2007-02-12 21:13:01 +00:00
|
|
|
--TEST--
|
|
|
|
Bug #40451 (addAttribute() may crash when used with non-existent child node)
|
2007-07-16 13:46:38 +00:00
|
|
|
--SKIPIF--
|
|
|
|
<?php if (!extension_loaded("simplexml")) die("skip"); ?>
|
2007-02-12 21:13:01 +00:00
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$string = <<<XML
|
|
|
|
<?xml version="1.0"?>
|
|
|
|
<Host enable="true">
|
|
|
|
<Name>host.server.com</Name>
|
|
|
|
</Host>
|
|
|
|
XML;
|
|
|
|
|
|
|
|
$xml = simplexml_load_string((binary)$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
|