note 113604 added to domdocument.createentityreference

From: Date: Mon, 04 Nov 2013 06:00:14 +0000
Subject: note 113604 added to domdocument.createentityreference
Groups: php.notes 
Request: Send a blank email to php-notes+get-197420@lists.php.net to get a copy of this message
<?php /*Entity is a group of words which print a special symbol. Like if we want to show copy right symbol in html page then we use &copy; code and browser convert this to actual copyright symbol. There have lots of entity, you can find them all form http://dev.w3.org/html5/html-author/charref if you want to use < or > or both <> into a node value than xml will give and warning or make this value as a node. So tell the xml parser that < or > is not tag symbol it is a entity.To do that you have to right &lt(<) and &gt;(>) instead of < and > symbol. Entity references always begin with an ampersand (&) and end with a semicolon (;). DO not need to use & and ; symbol begin and end of entity.Remove it when you want to use it to DOMDocument::createEntityReference Then append to to a tag where you want to show this symbol.Like below */ $dom=new DOMDocument("1.0","UTF-8"); $example=$dom->createElement("example","This is copyright "); $entity=$dom->createEntityReference("copy"); $example->appendChild($entity); $dom->appendChild($example); echo $dom->saveXML(); output is This is copyright © ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/domdocument.createentityreference.php Edit -- https://master.php.net/note/edit/113604 Del: integrated -- https://master.php.net/note/delete/113604/integrated Del: useless -- https://master.php.net/note/delete/113604/useless Del: bad code -- https://master.php.net/note/delete/113604/bad+code Del: spam -- https://master.php.net/note/delete/113604/spam Del: non-english -- https://master.php.net/note/delete/113604/non-english Del: in docs -- https://master.php.net/note/delete/113604/in+docs Del: other reasons-- https://master.php.net/note/delete/113604 Reject -- https://master.php.net/note/reject/113604 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#197420) next »