XML::Writer::Lazy - Pass stringified XML to XML::Writer
version 0.05
Pass stringified XML to XML::Writer
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>");
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.
startTag
endTag
Using a SAX parser whose events are then passed back to XML::Writer.
This is a subclass of XML::Writer.
Call's XML::Writer's new() and then instantiates the lazy parser pieces. Accepts all the same arguments as the parent method.
new()
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.
<foo><bar>asdf
<foo
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.
OUTPUT
print
Peter Sergeant - pete@clueball.com
pete@clueball.com
https://github.com/pjlsergeant/p5-xml-writer-lazy
MIT - see the LICENSE file included in the tar.gz of this distribution.
LICENSE
To install XML::Writer::Lazy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::Writer::Lazy
CPAN shell
perl -MCPAN -e shell install XML::Writer::Lazy
For more information on module installation, please visit the detailed CPAN module installation guide.