Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting XML Numbered Entities with PHP 5 DOM
    primarykey
    data
    text
    <p>I am new here and got a question that is tricking me all day long.</p> <p>I've made a PHP script, that reads a website source code through cURL, then works with DOMDocument class in order to generate a sitemap file.</p> <p>It is working like a charm in almost every aspect. The problem is with special characters.</p> <p>For compatibility reasons, sitemap files needs to have all special chars encoded as numbered entities. And I am not achieving that.</p> <p>For example, one of my entries - automatically read from site URLs, and wrote to sitemap file - is:</p> <p><em><a href="http://www.somesite.com/servi%C3%A7os/redesign/" rel="nofollow noreferrer">http://www.somesite.com/serviços/redesign/</a></em></p> <p>On the source code it should looks like:</p> <p>*<a href="http://www.somesite.com/servi" rel="nofollow noreferrer">http://www.somesite.com/servi</a>**&#231;**os/redesign/*</p> <p>Just this. But unfortunately, I am really not figuring it out how to do it.</p> <p>Source code file, server headers, etc... everything is encoded as UTF-8.</p> <p>I'm using DOMDocument and related extensions to build the XML. (Basically, DOMDocument, $obj->createElement, $obj->appendChild).</p> <p>htmlentities gives <strong>&ccedil;</strong> instead of <strong>&#231;</strong> str_replace does not work. It makes the character just vanish in the output.</p> <p>I was using $obj->createElement("loc", $url); on my code, and just now I read in PHP manual that I should use $document->createTextNode($page), in order to have entities encoding support.</p> <p>Well, it is not working either.</p> <p>Any idea on how to get unstuck of this?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload