in reply to Parsing badly formed RSS or XML
XML parsers are supposed to barf on non-wellformed XML - it's in the spec. You should shout at whoever gives you the XML until they fix their output.
In the meantime, you can make your parsing script die a little more gracefully by using eval like this:
--my $file = 'file.rss'; my $p = XML::RSS->new; eval { $p->parsefile($file) }; if ($@) { die "Bad XML document!!\n"; } else { print "Good XML!\n"; }
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Parsing badly formed RSS or XML
by tomhukins (Curate) on Feb 22, 2001 at 21:36 UTC | |
by davorg (Chancellor) on Feb 22, 2001 at 21:43 UTC | |
by tomhukins (Curate) on Feb 22, 2001 at 22:08 UTC |