iPhone中的xml解析问题 [英] xml parsing problem in iPhone

查看:80
本文介绍了iPhone中的xml解析问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个中文的xml提要,NSXLParsers无法解析.解析时给出错误31.

I have this xml feed in Chinese, which NSXLParsers is unable to parse. It gives error 31 while parsing.

由于文档编码未知而发生错误31.

error 31 occur due to Document encoding is unknown.

我尝试了UTF-8和ascii编码来转换通过

I tried UTF-8 and ascii encodings to convert string rendered via

[NSString stringwithContentsOfURL:@"http://news.baidu.com/n?cmd=4&class=finannews&tn=rss"]

更改为相应的格式.

任何人都可以阐明如何解析用另一种语言编写的XML提要.

Can any body shed some light on how to parse XML feeds written in another languages.

先感谢

推荐答案

尝试使用

- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
    NSString * errorString = [NSString stringWithFormat:@"Unable to download story feed from web site (Error code %i )", [parseError code]];
    NSLog(@"error parsing XML: %@", errorString);

    UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Error loading content" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [errorAlert show];
}

这将有助于查找问题是出在xml还是在编码方法上

It will help to find whether the problem is with the xml or the encoding method

这篇关于iPhone中的xml解析问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆