note 57154 deleted from function.dom-domelement-setattribute by didou

From: Date: Mon, 17 Apr 2006 12:56:20 +0000
Subject: note 57154 deleted from function.dom-domelement-setattribute by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-108329@lists.php.net to get a copy of this message
Note Submitter: Séb. ---- Note that attributes are *automatically* HTML-escaped. <?php $dom = DOMDocument::loadXML('<root/>') ; $value = '<' ; // Special HTML char that should be escaped $dom->documentElement->setAttribute('ok', $value) ; $dom->documentElement->setAttribute('ko', htmlspecialchars($value)) ; echo $dom->saveXML( ) ; ?> Gives : <?xml version="1.0"?> <root ok="&lt;" ko="&amp;lt;"/> /root[@ok] has been nicely auto-escaped whereas /root[@ko] has been finally badly escaped twice (later you will retrieve &lt; instead of <). So, don't send HTML-escaped strings.

« previous php.notes (#108329) next »