Discussion:
Umlaut in XML
(too old to reply)
Waldy
2008-11-27 17:18:19 UTC
Permalink
Hi there,
can anyone tell me how to represent an umlaut (ä) in XML?

I've tried &amul; and ä but they don't work.
Julian F. Reschke
2008-11-27 18:52:23 UTC
Permalink
Post by Waldy
Hi there,
can anyone tell me how to represent an umlaut (ä) in XML?
I've tried &amul; and ä but they don't work.
ä should work only work when declared in the DTD. ä should
work out of the box. It's also possible to use the character as is, as
long as you properly declare the encoding of the XML document.

So *how* didn't ä work?

BR, Julian
Peter Flynn
2008-11-27 20:48:47 UTC
Permalink
Post by Julian F. Reschke
Post by Waldy
Hi there,
can anyone tell me how to represent an umlaut (ä) in XML?
I've tried &amul; and ä but they don't work.
ä should work only work when declared in the DTD. ä should
work out of the box. It's also possible to use the character as is, as
long as you properly declare the encoding of the XML document.
The default is UTF8, so on most modern systems you just type ä. There
should be no need to use a character reference unless you are trying for
compatibility with other systems.
Post by Julian F. Reschke
So *how* didn't ä work?
Quite :-)

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Waldy
2008-11-28 10:25:27 UTC
Permalink
I am trying to use this in a standard .Net configuration file. Hi The
encoding is declared at the top of the file as utf-8. I get an XML
exception when I use the umlaut, "Invalid character in the given encoding".
If I change it to ä I get the error "Reference to undeclared entity".
I have however tried using ä again and it works! I don't know what
happened the first time, but thanks anyway.
Peter Flynn
2008-12-01 00:16:47 UTC
Permalink
Post by Waldy
I am trying to use this in a standard .Net configuration file. Hi The
encoding is declared at the top of the file as utf-8.
Just saying that the file is encoded in UTF-8 doesn't mean that it is.
Like putting a label on your toothpaste tube that says "Tomato puree"
doesn't make it tomato puree. The file has to BE in UTF-8.
Post by Waldy
I get an XML
exception when I use the umlaut, "Invalid character in the given encoding".
That indicates that the file is not in UTF-8.
Post by Waldy
If I change it to ä I get the error "Reference to undeclared entity".
Correct. If you want to use named character entity references you must
declare them in a DTD or an internal subset, eg

<?xml version="1.0"?>
<!DOCTYPE whatever [
<!ENTITY uuml "&#228;">
]>
Post by Waldy
I have however tried using &#228; again and it works!
Yes, numeric references work everywhere.
Post by Waldy
I don't know what happened the first time, but thanks anyway.
Check the encoding of the file. If it's not UTF-8, use iconv or whatever
the equivalent is in Windows to convert it. If you can't convert it,
change the encoding declaration to say what is really being used (eg
ISO8859-1). Leaving it broken will cause subsequent users problems.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Loading...