å in xml file is valid or not?

孤街浪徒 提交于 2020-06-27 09:25:13

问题


IE doesn't like the å character in an XML file to display. Is that an IE problem or are å and alike chars indeed invalid XML and do i have to create the &#xxx; values for all these letters?

Michel

by the way: the chars are inside a CDATA tag

The declaration is this: hmm, can't seem to get the xml declaration pasted in my post, it gets deleted or hidden in the html of my post i think, tried the backtick, 4 spaces etc to mark it as code. However, it's the same as sais in the answers

The declaration is this:

<?xml version="1.0" encoding="utf-8"?>

The snippet is

<resource key="erroraspx-errorDescription" value="cdata">  
<![CDATA[Något gick fel. Klicka <a href=".">här</a> för att gå till webbsidan ]]>  
</resource>  

回答1:


I am pretty sure that this is an encoding problem. You need to check that the encoding of your file is indeed something internationalised, like UTF-8, and that the xml header indicates this.

The xml file should start with <?xml version="1.0" encoding="UTF-8"?>




回答2:


I would think that would depend on the character set/encoding you had defined for the XML file.




回答3:


My guess is that your text in encoded in ISO-8859-1 since that is commonly used in Sweden.

Try adding:

<?xml version='1.0' encoding='ISO-8859-1'?>

I would consider converting the text to UTF-8.




回答4:


You allways can use entities as this:

<test>
&#228;
&#252;
&#229;
</test>

to get:

<test>
ä
ü
å
</test>

Maybe not exactly what you want, but a nice workaround. You can use sites like utf8-chartable.de to look up the needed value.




回答5:


This is an encoding issue. If the encoding of the file is provided in the xml, it should be recognized correctly. If your file is latin1, for example, the xml must start with this line:

<?xml version="1.0" encoding="ISO-8859-1"?>

You can omit the encoding attribute, determining the default encoding of the xml can be a bit tricky, though.




回答6:


Make sure that you actually save the file using the encoding that is specified in the XML.

The Notepad for example by default saves files as ANSI rather than UTF-8. Use the "Save As..." option so that you can specify the encoding.

I saved your XML as an UTF-8 file, and that shows up just fine in IE.



来源:https://stackoverflow.com/questions/1485955/%c3%a5-in-xml-file-is-valid-or-not

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!