parsing xml with php generates error for street names with apostrophes -


i'm trying parse xml using php. establish connection database , try fetch rows php , fed them xml markers google map. have problem streets have apostrophe in name (e.g. charles de gaulle'a):

header('content-type: application/xml; charset="utf-8"'); echo '<?xml version="1.0" encoding="utf-8"?>';  print "<markers>\n";  while ($row = oci_fetch_array($stid, oci_assoc+oci_return_nulls)) {      $location = "<mar ";     $location .= ' lgt=' . "'" . (str_replace(',', '.', $row['longtitude'])) . "'";     $location .= ' lat=' . "'" . (str_replace(',', '.', $row['latitude'])) . "'";     $location .= ' street=' . "'" . ($row['street']) . "'";     $location .= " />\n";     $output = $location;      print ($output); } print "</markers>\n"; 

this works fine when there no streets apostrophes inside, street returns error:

xml parsing error: not well-formed location: http://mywebsite.com/parsexml.php line number 5178, column 141: 

question how can fix no xml parsing error returned , markers generated without problems.

thank

you need use htmlentities() encode data. changing quotes cause problems when other quote used. should use htmlentities().


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -