79
|
0 |
0 |
0 |
$$self{'dom'} ||= do {
my($parser, $dom);
if ($parser = $$self{'libxml'}) {
if (defined $$self{'name'}) {
$self->throw("failed to parse $$self{'name'}: $@") unless eval {
do {
$dom = $parser->parse_file($$self{'name'})
}
};
}
else {
$self->throw("failed to parse file handle: $@") unless eval {
do {
$dom = $parser->parse_fh($$self{'handle'})
}
};
};
}
else {
$self->throw("XML::DOM not available: $@") unless eval {
do {
require XML::DOM
}
};
$parser = 'XML::DOM::Parser'->new(%$args) || $self->throw('failed to create parser');
if (defined $$self{'name'}) {
$self->throw("failed to parse $$self{'name'}: $@") unless eval {
do {
$dom = $parser->parsefile($$self{'name'})
}
};
}
else {
local $/ = undef;
my $fh = $$self{'handle'};
my $text = <$fh>;
$self->throw("failed to parse $$self{'name'}: $@") unless eval {
do {
$dom = $parser->parse($text)
}
};
};
};
$dom
} |