I am sending a xml document with grails to the webbrowser and want to show parts of it. However i get an error. I debugged and the error was because of the special charakters like ü,ö a.s.o In Firefox I dont have any problems, it works. However Internet Explorer 8 doesnt load the xml. I looked at the response, and saw, that it cannot get the ü,ö a.s.o correctly. It gets rectangles instead of it ....
Here is the xml file:
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<IOX_Commands>
<IOX_Device>
<cmd num="4" name="Delete" value="msg" desc="Meldungen len"/>
</IOX_Device>
<IOX_Commands>
Here is the grails part:
def get_Commands={
//aus xml datei lesen:conf/IOX_commands.xml
def file开发者_开发技巧 = "/conf/IOX_commands2.xml"
def xmlfile = new File(file).text
def xmlrecords = new XmlParser().parseText(xmlfile)
response.contentType = "text/xml";
render(xmlfile)
}
and here is the javascript part:
if (window.DOMParser)
{
parser=new DOMParser();
msrctl_steuerworte_var.ioxCommands=parser.parseFromString(response.responseText,"text/xml")
}
else // Internet Explorer
{
msrctl_steuerworte_var.ioxCommands=new ActiveXObject("Microsoft.XMLDOM");
msrctl_steuerworte_var.ioxCommands.async="false";
msrctl_steuerworte_var.ioxCommands.load(response.responseText);
}
//....
When I try to validate the xml file at http://www.w3schools.com/XML/xml_validator.asp I get an error.
Can someone say how to fix the problem? I already tried to make the file and the encoding UTF-8, but it doesnt help. I think its either an IE config or i have to add something to the grails controller.
I already tried to make the file and the encoding UTF-8, but it doesnt help.
But it should. Just be sure to convert the actual contents into UTF-8 - just changing the header won't help.
ok i think i solved a part of the problem with:
def get_Commands={ //aus xml datei lesen:
conf/IOX_commands.xml def file =
"/conf/IOX_commands2.xml" def xmlfile = new File(file).text
def xmlrecords = new XmlParser().parseText(xmlfile)
response.contentType = "text/xml";
render(text:xmlfile,contentType:"text/xml",encoding:"ISO-8859-1")}
精彩评论