Hi All,

I got some pretty strange problems using XML::Writer where the file that
I'm
writing to ends up with almost twice the data that I'm trying to write.
I'll
try to make a simple example (in the order of operation) since the code
I'm 
using is quite long. 

---- In Init.pm I have something like this: ----

use strict;
use IO;
use POSIX qw(strftime);
use XML::Writer;

    my $log = "/usr/builds/bldlog.xml";
    my $xmllog = new IO::File("> $log");
    my $writer = new XML::Writer(OUTPUT => $xmllog, DATA_MODE => 'true',
DATA_INDENT => 2);
    $writer->xmlDecl('UTF-8');
    $writer->comment("Build Log");
    $writer->startTag('Build');
    my $time = strftime "%m-%d-%Y %H:%M:%S", localtime;
    $writer->dataElement("Time","$time");

    return ($writer);

---- In Main.pl I have this ----

    my $xmlwr = Init();
    Display($xmlwr);
    SRC($xmlwr);
    ...

---- In Display.pm I have this ----

    $writer->startTag('Display');
    $writer->startTag('Variables');
    foreach my $key (sort keys %hash) {
        $writer->dataElement("$key","$hash{$key}");
    }
    $writer->endTag('Variables');
    $writer->endTag('Display');

---- In SRC.pm I have the final stage ----

    $writer->startTag('CVS');
    $writer->dataElement("Tag","$TAG");
    $writer->startTag('Files');
    open(CVS, "< $cvslog");
    while(<CVS>) {
        $writer->characters("$_");
    }
    close(CVS);
    $writer->endTag('Files');
    $writer->endTag('CVS');

---- END ----
<?xml version="1.0" encoding="UTF-8"?>
<!-- Build Log -->
<Build>                                            
  <Time>12-01-2004 14:06:36</Time>
  <Display>
    <Variables>
      <ARGS>blah</ARGS>
      <NUM>27</NUM>
    </Variables>
  </Display><?xml version="1.0" encoding="UTF-8"?>  !!!!!!
<!-- Build Log -->
<Build>
  <Time>12-01-2004 14:06:36</Time>
  <Display>
    <Variables>
      <ARGS>blah</ARGS>
      <NUM>27</NUM>
    </Variables>
  </Display>
  <CVS>
    <Tag>suite-test-build-27</Tag>
     <Files>U suite/ant_include.xml
        U suite/build.pb_to_bin.sh
        U suite/build.properties
        U suite/build.xml
    </Files>
  </CVS>

As you can see above the xml is started again after the end Display tag.
I realize that I don't have an end tag but that shouldn't matter, should
it?
The time between the end Display tag is written and the CVS tag is
approximately
40 minutes while a rather long process runs gathering data.  I don't
know if
that would matter much.  Any help is appreciated.  Sorry for being so
long 
winded I just wanted to make this as clear as possible.

Thanks!

Carter.



_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to