in reply to newline behaviour with XML::Writer

Try creating the object with:

my $writer = new XML::Writer(OUTPUT => $output, DATA_MODE => 1, DATA_INDENT=>2);

As per XML::Writer POD the behavior of NEWLINES is exactly what you get, but DATA_MODE should do what you want:

DATA_MODE A true or false value; if this parameter is present and its value is true, then the module will enter a special data mode, inserting newlines automatically around elements and (unless UNSAFE is also specified) reporting an error if any element has both characters and elements as content.

Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."

Replies are listed 'Best First'.
Re^2: newline behaviour with XML::Writer
by antiplex (Initiate) on Sep 15, 2008 at 15:41 UTC
    thanks a lot for pointing that out!
    i tried to use DATA_MODE together with NEWLINES which did not help but what you pointed out works correct and is plain simple. ... stupid me ... guess it's still along way to enlightenent for me ;)

    i'm still wondering which use the newlines parameter has, what use is the NEWLINES garbeled output?

      Dunno. My guess is that it is to obtain the shortest possible lines without inserting newlines within data. OTOH breaking a tag does not change the XML content.

      Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."