如何将所有类型的 rss feed 解析到 Android 中的单个 sax 解析器中
在我的应用程序中,我尝试解析 RSS feed url。它工作正常,没有任何错误。但现在我担心其他 rss feed 类型,例如 RDF 和 Autumn。
起初我对这些提要一无所知。现在的问题是,在我的应用程序中,当用户解析 RSS feed url 时,它会正常工作,但如果用户正在解析 RDF feed 或 Autumn feed,我确信它不会从这些 feed 中获取任何内容,因为开始标签所有这些提要都是不同的。
我担心这会在我的应用程序中产生问题,如何克服这个问题......
我知道我应该给出开始标签。我有一个逻辑想法,即为与 RSS feed、RDF feed 等相关的每个标签使用 switch case,但我不知道如何实现它......
请任何人帮助我......
in my app i am trying to parse an RSS feed url. Its working fine without any error. But now i am worried about the other rss feed types such as RDF and Autumn.
At first i dint have any idea about those feeds. Now the problem is, in my app when the user parses an RSS feed url it will work fine but if the user is parsing an RDF feed or Autumn feed i am sure that it will not get any content from those feeds, because the opening tags are different for all those feeds.
I am worrying that this will create problem in my app, how to overcome this problem...
I know that i should give the opening tags. I have a logical idea of using switch case for each tag that they related to RSS feed, RDF feed and so, but i dont know to implement it...
Please anyone help me.....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您在处理程序中的某个时刻会执行类似的操作
,并且您肯定可以选择
每个不同的开始标签名称。这就是说,如果您可以在解析提要类型之前获取/了解提要类型,那么对我来说,只需为每个提要类型使用不同的自定义 xml 解析器(例如 RSSXMLHandler、RDFXMLHandler 等)并像这样使用它们
,如果有一个更改 - - 例如,假设 RDF 提要的格式发生变化 - 您不必担心更新时会破坏 RSS/Autumn 等提要的读取。
I presume you at some point in your handler do something like
and there you can surely just go
for each of the various opening tag names. That said, it seems neater to me, if you can get/know the feed type before parsing it, to just have different custom xml parsers for each (like RSSXMLHandler, RDFXMLHandler, etc) and use them like
That way, if one changes -- eg, suppose the format of the RDF feed changes -- you don't have to worry about breaking the RSS/Autumn etc feed reading when updating it.