I'm now using NSXMLParser to parse html, but when meet "br" tag in html, it will throw an error for mismatch and stop to parse, because typically "/br" tag will not appear in html. So I want to ignore this mismatch error to continue parse, how to deal with it?
Asked
Active
Viewed 617 times
0
1 Answers
0
Not the best solution, but you might consider to do some regex correction before parsing, such as:
$input =~ s/<br>/<br \/>/ig;

Ωmega
- 42,614
- 34
- 134
- 203
-
should I do the same thing to all single tag like br? is this the only way? – Yuwen Yan Apr 20 '12 at 02:17
-
ybbaigo - It is kind of "hack" solution, as regex is not the best approach to deal with HTML/XML. Good parsers should do handle it, but if not, you can do this regex correction for any kind of tag... – Ωmega Apr 20 '12 at 11:25
-
-
. NSXMLParser will throw an error with br mismatch error info. – Yuwen Yan Apr 20 '12 at 11:18