[phpXML] Re: Dealing with HTML entities
Brought to you by:
bs_php,
nigelswinson
From: <lu...@sa...> - 2001-10-08 16:51:44
|
Hello, Here is the piece of code. // List of entities to be converted. // // This array contains a list of entities to be converted when an XPath // expression is evaluated. // // ### People seem to think that &apos is a bad idea for charset ISO-8859-1 //var $entities = array ( "&" => "&", "<" => "<", ">" => ">", // "'" => "'", '"' => """ ); var $entities = array('&'=>'&', '<'=>'<', '>'=>'>', '"'=>'"'); That means that if I do [....]<!CDATA[[<p>Hello world</p>]]>[...] The rendering will be <p>Hello world</p> And the browser will display <p>Hello world</p> The easiest (but probably not the safiest) solution is to emplty $entities, I have no problem with that because until now I use xml.php/xpath.class.php to read XML files not to produce XML files, but I suppose that emptying $entities is a bad thing to do when it comes to output XML. Luc En réponse à lu...@sa...: > Hello, > > With xml.php to have a correct rendering of HTML enclosed in XML tags > (in CDATA > sections) the array entities () might be emptied. If it was not the case > the > HTML entities where converted and then displayed by the browser in their > > literal form. > > It seem to be the same with xpath.class.php > > Im not in front of my development computer so I cant check the > xpath.class.php but the result shows that the behavior is the same. > > Instead of letting the user empty the array containing entities to > translate, > perhaps it would be a good thing to have a property to set (TRUE or > FALSE) > depending the behavior we need/want. > > > To go back to my test bed site :-) > > In the following example both the paragraph displayed in the center of > the > screen and the contextual menu in the left block came form the same XML > file. > > Here is the xml.php version with entities() emptied : > http://www.interpasnet.com/xmlprocess.php? > screen=cvs§ion=wincvs&file=cvs.xml&id=1 > HTML rendering is OK > > Here is the xpath.class.php version > http://www.interpasnet.com/xmlprocess.xpath.php? > screen=cvs§ion=wincvs&file=cvs.xml&id=1 > HTML entities contained in CDATA sections are converted so the browser > displays > them in their literal form > > > Luc > > -- > This message has been sent through the <phpXML/> user discussion list. > To unsubscribe, please visit > https://sslsites.de/mailinglisten/user/us...@li.../ > -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |