469,613 Members | 1,175 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,613 developers. It's quick & easy.

html_entity_decode when reading from a database

69
Hi,

I'm trying to read the results of a database query into an XML document but it's only read so far and stopping. The XML document is as follows:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <night>
  4.  
  5.   <name>Poontang</name>
  6.  
  7.   <homePageSummary>Launches 26th November</homePageSummary>
  8.  
  9.   <whatsOnPageSummary>Every Monday from 26th Nov Door price: 5/4 Guestlist (07809867930)</whatsOnPageSummary
  10.  
  11. >
  12.  
  13.   <description>Poontang is of course, a punch made from the fermented juice from the rare poonberry bush
  14.  
  15. . It became hugely popular during colonial times, it was a favourite of the Founding Fathers, drank constantly
  16.  
  17.  by George Washington, as evedenced by his farewell address, 'I only took the job for the poontang'.
  18.  
  19.  &lt;br /&gt;
  20.  
  21.  
  22. &lt;br /&gt;
  23.  
  24.  
  25. The first recorded recipe was printed in Ye Boston Globe. Unfortunately, poontang's immense popularity
  26.  
  27.  was later learned to be the result of addictive qualities. &lt;br /&gt;
  28.  
  29.  
  30. &lt;br /&gt;
  31.  
  32.  
  33. The hunger for good quality poontang is said to have made a Bishop kick a hole in a stained glass window
  34.  
  35. . Withdrawl will occur, leading to unappealing physical &amp;amp; mental consequences, including blue
  36.  
  37.  balls, hairy palms &amp;amp; lack of mental clarity. &lt;br /&gt;
  38.  
  39.  
  40. &lt;br /&gt;
  41.  
  42.  
  43. COME SEE THE POONTANG PANDA.... &lt;br /&gt;
  44.  
  45.  
  46. Performing its erotic pole dance routine &lt;br /&gt;
  47.  
  48.  
  49. Pouring free poontang punch from the stage &lt;br /&gt;
  50.  
  51.  
  52. Giveaway baby poontang panda cuddly toys &lt;br /&gt;
  53.  
  54.  
  55. and if your lucky he might just hump your leg! &lt;br /&gt;
  56.  
  57.  
  58. &lt;br /&gt;
  59.  
  60.  
  61. DRINKS &lt;br /&gt;
  62.  
  63.  
  64. Baby Champers 70p! &lt;br /&gt;
  65.  
  66.  
  67. Bottles of Sol &amp;amp; Sambucca Shots &amp;pound;1 &lt;br /&gt;
  68.  
  69.  
  70. Double Spirit &amp;amp; Mixer inc Red Bull &amp;pound;2.40 &lt;br /&gt;
  71.  
  72.  
  73. Poontang Pitchers &amp;amp; Red Pig Pithcers &amp;pound;5 &lt;br /&gt;
  74.  
  75.  
  76. Bottles of House Wine &amp;pound;7 &lt;br /&gt;
  77.  
  78.  
  79. &lt;br /&gt;
  80.  
  81.  
  82. MUSIC &lt;br /&gt;
  83.  
  84.  
  85. Big Panda Party Tunes -&amp;gt; Dance, R'n'B and Indie &lt;br /&gt;
  86.  
  87.  
  88. &lt;br /&gt;</description>
  89.  
  90.   <thumbnail>thumb447.jpg</thumbnail>
  91.  
  92.   <flyer>poon_flyer451.jpg</flyer>
  93.  
  94. </night>
  95.  
I'm using the following the try and sort out the entities.

Expand|Select|Wrap|Line Numbers
  1. function html_numeric_entities($str) 
  2.     return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); 
  3. }; 
  4.  
  5. $description = html_numeric_entities(html_entity_decode($row['description']));
  6. $description = $night->appendChild($dom->createElement('description', $description));
  7.  
But it's only getting so far. I've tried it with just html_entity_decode but it gets struck with ampersands and signs. So I be using htmlentities when writing to the database, along with addslashes and then html_entity_decode when reading from the database. I've also had problems with hyphens. The PHP code can create the database but the Javascript code that reads the XML document when I'm creating an Ajax.Request cannot.

Hopefully some kind soul can guide on what I'm doing wrong.

Thanks,

Sean
Nov 23 '07 #1
1 1916
pbmods
5,821 Expert 4TB
Heya, Sean.

Instead of worrying about HTML entities, try using CDATA tags.
Nov 26 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by HI-Lab * the Social Technology | last post: by
reply views Thread by lawrence | last post: by
10 posts views Thread by Markus Ernst | last post: by
1 post views Thread by sylvian stone | last post: by
1 post views Thread by =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.