Jump to content

Problem Parsing & From Xml


Obi1-Cannabis

Recommended Posts

heya,i'm using xml files to store words and small phrases in different languages.then i have a class that parses the xml file into an array and then the array into an object, it was working everything ok and it's still on localhost but on online server the & is beeing ignored.So if i have an entry like <excursoes>Excurs&otilde;es</excursoes> after parsing it when i do an echo that was suposed to echo Excursões it prints Excursotilde;es. does anyone has any idea why this could be happening, and only when online?

Link to comment
Share on other sites

This is correct behaviour. If you want an entity, you must explicitly write it. DOM doesn't "double decode" stuff for you. "otilde" is a named entity though, so to avoid the need to write the DTD into the XML (and making the XML load reeeealy slow), you should write the entity as "#245" or write the character directly, which is reccomended if the encoding of the XML is UTF-8.

Link to comment
Share on other sites

writing the entities like that isn't working either.you're saying that's correct behaviour, but it was working fine a while ago and is working also in my virtualhost on my computer.
Then write is as a numeric entity (#245 in this case).Or better yet, make sure the XML fine is encoded as UTF-8 and then write the character directly. To make sure it's UTF-8 encoded, while opening the file with Notepad, go to "File > Save as...", and from the "Encoding" menu select UTF-8. Save the file, then close it and reopen it. Then make sure the first line of the XML is something like
<?xml version="1.0" encoding="UTF-8"?>

. At that point, the XML should be UTF-8 encoded, and be read as such.

Link to comment
Share on other sites

numeric entities is what i said isn't working.if i declare the entities is it going to make the XML load that mutch slow?Because using the xml file as UTF-8 isn't going to help because the pages are encoded ISO-8859-1 and that makes the ç look like ç Also my database has the tables defaulted to latin-1 and there's already too much data in the database to change it to UTF-8 now, so changing the pages encoding is not a solution right now.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...