fionbarr has asked for the wisdom of the Perl Monks concerning the following question:

I am successfully creating XML files with XML::Writer. As an exercise I tried to parse these files with XML::LibXML.
It chokes on 'parser error : Extra content at the end of the document' +.
Turns out there's a <CTRL-Z> at the end of the created XML document. Has anyone encountered this? What might the work around be? I tried to remove it with a REGEX with no success.

Replies are listed 'Best First'.
Re: xml::writer and xml::LibXML
by runrig (Abbot) on May 15, 2013 at 16:14 UTC
    Doesn't make sense to me. Something else is going on. Try the simplest thing possible:
    use strict; use warnings; use XML::Writer; open(my $fh, ">", "tmp.xml") or die "Err: $!"; my $w = XML::Writer->new( OUTPUT => $fh, ); $w->emptyTag('root'); $w->end(); close $fh;
      I don't get the ctrl-z with your file open procedure....here's what I'm using
      $xml_out = new IO::File(">$filename"); # 'OUTPUT' writes to this file # 'DATA_MODE' writes <CRLF> after each line # 'DATA_INDENT' indents each level four spaces $xml_writer = new XML::Writer( OUTPUT => $xml_out, DATA_MODE => 'true', DATA_INDENT => 4 );
      I'll give your open routine a shot....thanks
        it looks like that did it! Thank you.