Best way to parse XML data of non-ASCII encoding...?
Best way to parse XML data of non-ASCII encoding...?
- Subject: Best way to parse XML data of non-ASCII encoding...?
- From: Simon Liu <email@hidden>
- Date: Tue, 5 Apr 2005 18:12:16 +0100
Hi,
I am doing some XML parsing for 10.2+, thus I am using Core
Foundation's XML functions, such as CFXMLTreeCreateFromData().
Things are working fine except for XML files with non-ASCII
characters. The functions seem to ignore the encoding attribute of
the xml tag, such as in:
<?xml version="1.0" encoding="shift_jis" standalone="yes"?>
Given an XML file in the above encoding, with Japanese characters as
values between tags, the routines crash.
However, if I first convert the file to UTF8, things work fine...
NSString *s = [NSString stringWithContentsOfURL:sourceURL];
NSData *xmlData = [s dataUsingEncoding:NSUTF8StringEncoding];
// use as CFDataRef in CFXMLTreeCreateFromData()
Is this the expected behaviour? Is there a more elegant way to parse
non-ASCII XML files?
Regards,
Simon
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden