Quicksilver has asked for the wisdom of the Perl Monks concerning the following question:
The XML I'm getting is:#!c:\perl\bin\perl.exe use strict; use warnings; use XML::Writer; use IO::File; my $write; my $file = "C:\\WebRoot\\dickens\\dicktest.txt"; my @outputxml; my $output = new IO::File(">c:\\generate.xml"); my $count; my $writer = new XML::Writer(OUTPUT => $output); open (IN, $file) || die "$file not found\n"; @outputxml = <IN>; close (IN); chomp @outputxml; $writer->xmlDecl(); $writer ->startTag("text"); foreach $write ( @outputxml) { $count++; $writer ->startTag("lineno"); $writer->characters($count); $writer->endTag("lineno"); $writer ->startTag("line"); $writer->characters($write); $writer->endTag("line"); } $writer->endTag("text"); $writer->end(); $output->close();
so the XSL is only transforming the first couple of elements and then ignoring the rest of the file so I can see STAVE I: MARLEY'S GHOST but not the rest of the file. If I put the $writer->startTag("text") and its closing tag inside the for loop, the transformation fails whilst parsing.<?xml version="1.0"?> <text><br /> <lineno>1</lineno><line>STAVE I: MARLEY'S GHOST</line><br /> <lineno>2</lineno><line></line><br /> <lineno>3</lineno><line>MARLEY was dead: to begin with. There is no do +ubt</line>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML output question
by pc88mxer (Vicar) on Apr 11, 2008 at 17:02 UTC |