Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Catch XML error

by philcrow (Priest)
on Jul 13, 2007 at 20:44 UTC ( [id://626535]=note: print w/replies, xml ) Need Help??


in reply to Catch XML error

Try wrapping in eval:
my $value; eval { $value = $record1->getAttribute('value1'); }; next FILE if ( $@ );

Note the scope. Define the variable outside the eval, or you'll only be able to use it in the block.

Phil

The Gantry Web Framework Book is now available.

Replies are listed 'Best First'.
Re^2: Catch XML error
by kyle (Abbot) on Jul 13, 2007 at 23:31 UTC

    Note that the eval will catch all errors, not just this one. It might be prudent to look at the contents of $@ (see perlvar) to see if the error you caught is really the one you want to skip silently.

    my $value; eval { $value = $record1->getAttribute('value1'); }; if ( $@ ) { next FILE if ( $@ =~ /^duplicate attribute/ ); die $@; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://626535]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2024-03-28 12:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found