logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

XML::Writer::String - Capture output from XML::Writer.

Author

       Simon Oliver <simon.oliver@umist.ac.uk>

Description

       This module implements a bare-bones class specifically for the purpose of capturing data from the
       XML::Writer module.  XML::Writer expects an IO::Handle object and writes XML data to the specified object
       (or STDOUT) via it's print() method.  This module simulates such an object for the specific purpose of
       providing the required print() method.

       It is recommended that $writer->end() is called prior to calling $s->value() to check for well-
       formedness.

Methods

       XML::Writer::String provides three methods, "new()", "print()" and "value()":

       "$s = XML::Writer::String-"new([list]);>
           new() returns a new String handle.

       "$count = $s-"print([list]);>
           print() appends concatenated list data and returns number of items in list.

       "$val = $s-"value([list]);>
           value()  returns  the  current  content  of  the  object  as  a  scalar.   It  can  also  be  used to
           initialize/overwrite the current content with concatenated list data.

Name

       XML::Writer::String - Capture output from XML::Writer.

Notes

       This module is designed for the specific purpose of capturing  the  output  of  XML::Writer  objects,  as
       described  in  this  document.  It does not inherit form IO::Handle.  For an alternative solution look at
       IO::Scalar, IO::Lines, IO::String or Tie::Handle::Scalar.

See Also

       XML::Writer, IO::Handle, IO::Scalar

perl v5.36.0                                       2022-10-13                                        String(3pm)

Synopsis

         use XML::Writer;
         use XML::Writer::String;

         my $s = XML::Writer::String->new();
         my $writer = new XML::Writer( OUTPUT => $s );

         $writer->xmlDecl();
         $writer->startTag('root');
         $writer->endTag();
         $writer->end();

         print $s->value();

See Also