antiplex has asked for the wisdom of the Perl Monks concerning the following question:
in the putput-file (testout.xml) i find after running the above:use strict; use XML::Writer; use IO::File; my $output = new IO::File(">testout.xml"); my $writer = new XML::Writer(OUTPUT => $output, NEWLINES => 1); $writer->xmlDecl(); $writer->startTag("rootnode", "xmlns" => "my:name:space", "version" => + "1", "creator" => "anti"); $writer->emptyTag("emptynode", "value" => "abc"); $writer->startTag("node", "name" => "foo"); $writer->characters("Hello, world!"); $writer->endTag("node"); $writer->endTag("rootnode"); $writer->end(); $output->close();
but i would prefer this to look like:<?xml version="1.0"?> <rootnode xmlns="my:name:space" version="1" creator="anti" ><emptynode value="abc" /><node name="foo" >Hello, world!</node ></rootnode >
indenting is useful but not as important as getting the lines wrapped nicely.<?xml version="1.0"?> <rootnode xmlns="my:name:space" version="1" creator="anti"> <emptynode value="abc" /> <node name="foo"> Hello, world! </node> </rootnode>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: newline behaviour with XML::Writer
by psini (Deacon) on Sep 13, 2008 at 20:48 UTC | |
by antiplex (Initiate) on Sep 15, 2008 at 15:41 UTC | |
by psini (Deacon) on Sep 15, 2008 at 18:55 UTC |