Peter Sergeant
and 1 contributors

NAME

XML::Writer::Lazy - Pass stringified XML to XML::Writer

VERSION

version 0.05

DESCRIPTION

Pass stringified XML to XML::Writer

SYNOPSIS

    my $writer = XML::Writer::Lazy->new( OUTPUT => 'self');
    my $title  = "My Title!";

    $writer->lazily(<<"XML");
        <html>
            <head>
                <title>$title</title>
        </head>
        <body>
            <p>Pipe in literal XML</p>
    XML

    $writer->startTag( "p", "class" => "simple" );
    $writer->characters("Alongside the usual interface");
    $writer->characters("123456789");
    $writer->lazily("</p></body></html>");

WHY

This is 2016. The computer should do the hard work. Life's too short to write a bunch of startTag and endTag when my computer's perfectly capable of figuring out the right thing to do if I give it a chunk of XML.

HOW

Using a SAX parser whose events are then passed back to XML::Writer.

METHODS

This is a subclass of XML::Writer.

new

Call's XML::Writer's new() and then instantiates the lazy parser pieces. Accepts all the same arguments as the parent method.

lazily

Take a string of XML. It should be parseable, although doesn't need to be balanced. <foo><bar>asdf is fine, where <foo is not. Exercises the XML::Writer methods appropriately to re-create whatever you'd passed in.

wrap_output

Only important if you're doing strange things with the OUTPUT after instantiation. In order to keep track of what's been written already, this class wraps the OUTPUT object inside a delegate that intercepts and stores the contents of print. If you -- post instantiation -- replace the output object, you can call this method to rewrap it. It will change the class that that object belongs to.

AUTHOR

Peter Sergeant - pete@clueball.com

https://github.com/pjlsergeant/p5-xml-writer-lazy

LICENSE

MIT - see the LICENSE file included in the tar.gz of this distribution.