[Melbourne-pm] XML parsing

Alfie John alfiejohn at gmail.com
Mon Mar 21 21:23:51 PST 2005


Hi guys,

Just a quicky...

I have some XML (quite small) to parse but want it done elegantly, so I 
thought that XML::Simple would be the way to go. However the XML might 
be a bit dodgy, so I also wanted to validate it.

The problem is that XML::Simple gives nice data structures, but if the 
XML is invalid it will hang or take a very long time to parse (very 
bad!). On the flip-side, XML::Parser will let me know if it's invalid by 
dieing (which is what I want instead of hanging), but gives ugly data 
structures compared to XML::Simple.

So the way i'm thinking to combine the best of both worlds is to first 
let XML::Parser parse it and if $@ doesn't get set, keep going with 
XML::Simple.

Does anyone have any suggestions on a better way of doing this?

Thanks.

int 20h;
Alfie John


More information about the Melbourne-pm mailing list