note 57154 added to function.dom-domelement-setattribute

From: Date: Sun, 25 Sep 2005 17:39:32 +0000
Subject: note 57154 added to function.dom-domelement-setattribute
Groups: php.notes 
Request: Send a blank email to php-notes+get-95761@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.dom-domelement-setattribute.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57154 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57154&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57154&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57154&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57154&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57154&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57154&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57154&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57154&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#95761) next »