1--TEST-- 2Bug #38424 (Different attribute assignment if new or exists) 3--SKIPIF-- 4<?php if (!extension_loaded("simplexml")) print "skip"; ?> 5--FILE-- 6<?php 7 8$xml = simplexml_load_string('<xml></xml>'); 9 10$str = "abc & def" ; 11 12$xml["a1"] = "" ; 13$xml["a1"] = htmlspecialchars($str,ENT_NOQUOTES) ; 14 15$xml["a2"] = htmlspecialchars($str,ENT_NOQUOTES) ; 16 17$xml["a3"] = "" ; 18$xml["a3"] = $str ; 19 20$xml["a4"] = $str ; 21 22echo $xml->asXML(); 23?> 24--EXPECT-- 25<?xml version="1.0"?> 26<xml a1="abc &amp; def" a2="abc &amp; def" a3="abc & def" a4="abc & def"/> 27