1--TEST-- 2SimpleXML: Attribute creation 3--SKIPIF-- 4<?php 5 if (!extension_loaded('simplexml')) print 'skip'; 6?> 7--FILE-- 8<?php 9 10$xml =<<<EOF 11<?xml version="1.0" encoding="ISO-8859-1" ?> 12<foo/> 13EOF; 14 15$sxe = simplexml_load_string($xml); 16 17try { 18 $sxe[""] = "value"; 19} catch (ValueError $exception) { 20 echo $exception->getMessage() . "\n"; 21} 22 23$sxe["attr"] = "value"; 24 25echo $sxe->asXML(); 26 27$sxe["attr"] = "new value"; 28 29echo $sxe->asXML(); 30 31try { 32 $sxe[] = "error"; 33} catch (ValueError $exception) { 34 echo $exception->getMessage() . "\n"; 35} 36 37__HALT_COMPILER(); 38?> 39===DONE=== 40--EXPECT-- 41Cannot create attribute with an empty name 42<?xml version="1.0" encoding="ISO-8859-1"?> 43<foo attr="value"/> 44<?xml version="1.0" encoding="ISO-8859-1"?> 45<foo attr="new value"/> 46Cannot append to an attribute list 47