Re: [xml] question about how to set namespace in libxml



Michael Ludwig schrieb am 06.03.2011 um 12:43 (+0100):

my $dtdchunk = read_file $dtdfile;
my $parser = XML::LibXML->new;

foreach ( @xmlfiles ) {
        my $xmlchunk = read_file $_;
        $parser->parse_chunk( $dtdchunk );
        my $doc = $parser->parse_chunk( $xmlchunk, 1 );
        print $doc->toString, "\n\n";
}

There are problems with this approach, of course.

You have to know or detect the encoding of each chunk you want to parse.

You have to make sure there is no XML declaration on any chunk that is
not right at the start of the document.

-- 
Michael Ludwig



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]