David Phillip Oster wrote:
> In article
> <lazloman-91EB72.20371028042008@[EMAIL PROTECTED]
>,
> Can I Get a Word In <lazloman@[EMAIL PROTECTED]
> wrote:
>
>> I'm using NSXMLParser to read an XML do***ent from a server via
>> initiWithContentsOfURL. This works just fine under Leopard. I can read
>> and parse the data just fine, but under Tiger, I get an empty do***ent
>> error: NSXMLParserErrorDomain = 4 (Empty do***ent). There are several
>> posts in the archives about problems with NSXMLParser, but nothing
>> suggesting a Tiger bug leading to an empty do***ent. Unless someone
>> thinks there's something wrong with my code, I'm going to file a bug
>> with Apple.
>>
>> Here is my code:
>> NSXMLParser* locationData = [[[XMLParser alloc]
>> initWithContentsOfURL:[NSURL URLWithString:urlString]] autorelease];
>> [locationData setDelegate:self];
>> [locationData parse];
>> NSError* err = [locationData parseError]; <---Empty do***ent error
>>
>>
>> urlString is an NSString that was created using
>> stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding
>>
>> The do***ents encoding is actually Latin1, I pasted the last one I
tried
>> here. I've tried a few encodings, but they all fail with the same
error.
>> Any ideas?
>
> Do an NSData initWithContentsOfURL:, and see if you can convert it to a
> UTF8String, If you can't, you certainly couldn't expect NSXMLParser to
> handle it.
>
> Save the NSData to a file, and use the command line tool:
>
> tidy -e -xml -utf8 inFile
>
> and it will tell you about malformed XML.
I've already tried using NSString's initWithContentsOfURL, passing the
data returned from dataUsingEncoding to NSXMLParser's intiWithData
initializer. I ended up with a bunch of unicode escape sequences as an
NSString and the parser still failed with the same error as before.
I'll try your suggestion later, when I get home.


|