Using an NSXMLParser to parse HTML

前端 未结 3 2037
眼角桃花
眼角桃花 2020-12-07 03:42

I\'m working on an app which aggregates some feeds from the internet and reformats the content. So I\'m looking for a way to parse some HTML. Given XML and HTML are very sim

3条回答
  •  遥遥无期
    2020-12-07 04:44

    HTML is not necessarily well-formed XML, and that's the trouble when you parse it as XML.

    Take the following example:

    
        

    123

    abc

    789

    If you view this chunk of html in a browser, it would show just as what you expected. But if you parse this as xml, there would be trouble, as those p tags are not closed.

提交回复
热议问题