PerlのXML::SimpleでEnd tag mismatch

            Perlの話です。

XML文字列のパースにXML::Simpleを使っていたら「End tag mismatch (hoge != foo) [Ln: 125, Col: 495518205]」ていうエラーがでた。

パーサーを変更して解決した。

[perl] use XML::Simple;

my $xml_string = ???; # XMLな文字列

パーサーをXML::Parserで指定する

$XML::Simple::PREFERRED_PARSER='XML::Parser';

my $xs = XML::Simple->new(keyattr => [], suppressempty => '', forcearray => 0); $xml_hash = $xs->XMLin($xml_string); [/perl]

XML::Simpleのデフォルトのパーサーは「XML::SAX」のようです。 おわり。

参考 http://www.perlmonks.org/?node_id=706838 http://iandeth.dyndns.org/mt/ian/archives/000589.html