I am doing an index page of thousands of DCRs. My TPL reads other DCRs and uses XMLnode, which works 99.9% of the time, except when (like during data import) there is a mistake in the XML and then XMLnode dies a horrid death and there is no easy way to debug. Since every once in a great while the DCRs get hand edited, there is a chance of bad XML.I could use XMLparser to check the XML first and then use XMLnode. But since this TPL already takes about 10 seconds to preview, I am not certain I want to add to the overhead.I am thinking I will need to see how long it takes. I am just curious what others do.Andy
... my $rootnode = undef; eval { $rootnode = TeamSite::XMLnode->new($xml); }; if ($@) { # error occurred - skip or do something } # use $rootnode as you were previously ...
Cool, that works nicely, thanks. I have to get my Perl book out & figure out what it did.Andy
I'll save you a bit of time - if you read the doc on TeamSite::XMLnode->new() - it tells you that if there is any problem it 'die's - well if you wrap the call in eval { ... }; you trap the 'die' signal information in $@ and so can do something more graceful.