Improve the selection of parser for XML::Simple.
[spider.git] / perl / DXXml.pm
index a351510c511f02ca0f8ce450bb3d3906c39f61c1..fe4cb2b8af8efc6affdc47079922e6f56f25e3c5 100644 (file)
@@ -41,11 +41,17 @@ sub init
 {
        return unless $main::do_xml;
        
-       eval { require XML::Simple; };
-       unless ($@) {
+       eval { require XML::Simple };
+       eval { require XML::SAX } unless $@;
+       eval { require XML::SAX::Expat } unless $@;
+       if ($@) {
+               LogDbg('err', "do_xml was set to 1 and the XML routines failed to load ($@)");
+               $main::do_xml = 0;
+       } else {
+               $XML::Simple::PREFERRED_PARSER = 'XML::SAX::Expat';
                import XML::Simple;
                $DXProt::handle_xml = 1;
-               $xs = new XML::Simple();
+               $xs = new XML::Simple(Cache=>[]);
        }
        undef $@;
 }