Compdigitec Labs

« | Home | »

Using (X)HTML entities in plain XML files

By admin | July 14, 2009

Update (2009-07-28): Here is a place that you can find accents for English characters.

If you try to use non-ASCII characters (e.g. accents) in directly in a Windows-1252 (ISO-8859-1) encoded web page directly without converting/transforming them into an entity, the web browser may get confused when the header of the web page is sent wrong or is misunderstood, resulting in garbled accents and even possibly mojibake.

The correct way to embed those into a web page are to use the corresponding (X)HTML entities such as ê for the ê accent. But if you try to load a string from a XML file into a web page (as many PHP scripts do nowadays), you will encounter a nasty error informing you that the entity was not defined (e.g. parser error : Entity ‘eacute’ not defined). To remedy this, in the XML file instead of the direct entity replace the ampersand (&) in the entity with its entity version. This may sound confusing at first but after a while it starts to make sense.

  • XML file display = ê
  • HTML source display = ê
  • Browser display = ê

If you found this article helpful or useful, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful or interesting articles!

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: (X)HTML | 3 Comments »

3 Responses to “Using (X)HTML entities in plain XML files”

  1. Mohamed Says:
    July 28th, 2009 at 21:31

    thanks alot it’s very helpful!

  2. pg slot เว็บตรง Says:
    November 2nd, 2024 at 04:31

    … [Trackback]

    […] Find More Info here to that Topic: compdigitec.com/labs/2009/07/14/using-xhtml-entities-in-plain-xml-files/ […]

  3. ทัวร์ Says:
    November 9th, 2024 at 09:17

    … [Trackback]

    […] Find More Info here on that Topic: compdigitec.com/labs/2009/07/14/using-xhtml-entities-in-plain-xml-files/ […]

Comments