Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-12-2011, 02:03 AM   PM User | #1
BrightNail
Regular Coder

 
Join Date: Jun 2002
Posts: 349
Thanks: 2
Thanked 0 Times in 0 Posts
BrightNail is an unknown quantity at this point
Another INVALID CHARACTER question

hello,

I have something weird going on.. I am using this:

var eventTags = transport.responseXML.getElementsByTagName( 'item' );

etc... all seemed great until I ran across some xml, out of the hundreds that I've tested that gave me this error:

An invalid character wa sfound in text content....

and the issue is this: geh�ren

here is the encoding being used: <?xml version="1.0" encoding="UTF-8"?>

I cannot alter the xml. I have to deal with it as it comes in. Is there anyway I can circumvent that error and still get the data? Perhaps offer an over-ride in html / javascript etc.. of course, this is only happening in IE, ff is fine.

I am asking for UTF encoding, there is latin in the XML --- is there ANY way (without me messing with the xml etc..) that i can still read this data in and act on it?

thanks

Last edited by BrightNail; 05-12-2011 at 02:35 AM..
BrightNail is offline   Reply With Quote
Old 05-12-2011, 01:52 PM   PM User | #2
flaMasta
New Coder

 
Join Date: Feb 2010
Location: Manchester, UK
Posts: 69
Thanks: 0
Thanked 13 Times in 13 Posts
flaMasta is an unknown quantity at this point
First of all, are you really sure that you are using utf-8 ?
what I understand:
you got some web file which through Ajax or in similar fashion gets contents of XML file (wherever it would be)

then you want to use some contents of the xml file ?

if you are sure that XML file that you read got coding set then the problem lay in your script which must work in different coding

on your website that you have script on you must set proper coding using appropriate style for the document you use

for example
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
flaMasta is offline   Reply With Quote
Old 05-14-2011, 12:23 AM   PM User | #3
BrightNail
Regular Coder

 
Join Date: Jun 2002
Posts: 349
Thanks: 2
Thanked 0 Times in 0 Posts
BrightNail is an unknown quantity at this point
hmmm. I tried that Meta tag implementation and it didn't work. The xml would still not render in IE.

So basically IF the xml is created with latin character code set and the reader (browser) is UTF, it errors out???? arghhh. any other way of solving this issue?

Can I somehow pass with the "transport.responseXML." some sort of flag that tells the xml to render or igore non-utf characters etc...?
BrightNail is offline   Reply With Quote
Old 05-14-2011, 12:44 AM   PM User | #4
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by BrightNail View Post
hmmm. I tried that Meta tag implementation and it didn't work. The xml would still not render in IE.

So basically IF the xml is created with latin character code set and the reader (browser) is UTF, it errors out???? arghhh. any other way of solving this issue?

Can I somehow pass with the "transport.responseXML." some sort of flag that tells the xml to render or igore non-utf characters etc...?
the xml is not in latin, this is the problem, is in utf-8 and another problems is that probably is invalid utf-8.
the word is probably 'gehüren' or 'gehören' and you need to use \uxxxx instead of that char in javascript where \uxxxx is the hex code for that char.

the declaration from xml prolog doesn't force the xml to have that encoding, if the author used another encoding in his editor or when he generate the xml, the xml is invalid.

best regards
oesxyl is offline   Reply With Quote
Old 05-17-2011, 11:32 PM   PM User | #5
BrightNail
Regular Coder

 
Join Date: Jun 2002
Posts: 349
Thanks: 2
Thanked 0 Times in 0 Posts
BrightNail is an unknown quantity at this point
Quote:
Originally Posted by oesxyl View Post
the xml is not in latin, this is the problem, is in utf-8 and another problems is that probably is invalid utf-8.
the word is probably 'gehüren' or 'gehören' and you need to use \uxxxx instead of that char in javascript where \uxxxx is the hex code for that char.

the declaration from xml prolog doesn't force the xml to have that encoding, if the author used another encoding in his editor or when he generate the xml, the xml is invalid.

best regards
Is there a way to encode the input prior to being written into xml.

The way our system is, the user enters data into a tool. The tool then sends the data to the backend in which it writes out the xml, and plops it into some directory.

Is there a way to do some javascript testing/scrubbing in that I can do the write thing prior to the xml being generated?
BrightNail is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:14 AM.


Advertisement
Log in to turn off these ads.