views:

296

answers:

2

Hi, I'm using NSXMLParser on an iPhone App to parse HTML Files for a RSS or Atom Feed Link.

Everything works fine until the parser find a <script> element that includes Javascript code without the CDATA Declaration, this causes a Parse Error.

Is possible to tell the parser to skip all the elements named <script>?

A: 

Why not just implement parser:parseErrorOccured: and tell it to fail gracefully? I don't believe there's a way to say 'skip this element'

refulgentis
Unfortunately I can't do it because I need to extract the link of an RSS Feed and then save it.I've tried on several pages and it works (also if parseErrorOccurred is called), but if there is a script tag before the link tag, the parser aborts without doin' anything.
Lex
A: 

It's not possible to my knowledge to just skip an element. However you may be able to use regex replacement to filter out the invalid content.

Another possibility would maybe to use Tidy to try to clean it up before parsing.

Bryan McLemore