Am creating XML sitemap using PHP. The XML values are from database and using below code to generate XML sitemap.
header("Content-Type: application/xml; charset=utf-8");
echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
$query = mysqli_query($connect, "SELECT * FROM `tbl_city_landing_pages` WHERE `city_landing_pages_status` = 1 ORDER BY `city_landing_pages_keyword` ASC");
$total = mysqli_num_rows($query);
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'.PHP_EOL;
while ($city_rows = mysqli_fetch_array($query)) {
echo '<url>'.PHP_EOL;
echo '<loc>'.BX_DOL_URL_ROOT.strtolower(str_replace(array(" ", "/"), array("-", "_"), $city_rows["city_landing_pages_keyword"])).'</loc>'.PHP_EOL;
echo '<lastmod>'.date('Y-m-d').'</lastmod>'.PHP_EOL;
echo '<changefreq>daily</changefreq>'.PHP_EOL;
echo '</url>'.PHP_EOL;
}
echo '</urlset>'.PHP_EOL;
The above code is working fine with some characters.
In my DB some row contains Bogotá, D.C.. And this character is not encoding even charset is utf-8. And the error shown is,
This page contains the following errors:
error on line 19 at column 6: Encoding error
Below is a rendering of the page up to the first error.
How to show all the text from DB.
Is there any solution for this. I need to display all the values from mysql DB.