Tags::Output::LibXML - Printing 'Tags' structure by LibXML library.
use Tags::Output::LibXML; my $tags = Tags::Output::LibXML->new(%parameters); $tags->put(['b', 'element']); my @open_tags = $tags->open_tags; $tags->finalize; $tags->flush($reset_flag); $tags->reset;
This class is only for XML structures.
new(%parameters)
Constructor.
cdata_callback
Subroutine for output processing of cdata. Input argument is reference to array. Default value is undef. Example is similar as 'data_callback'.
data_callback
Subroutine for output processing of data, cdata and raw data. Input argument is reference to array. Default value is undef. Example: 'data_callback' => sub { my $data_ar = shift; foreach my $data (@{$data_ar}) { # Some process. $data =~ s/^\s*//ms; } }
encoding
Encoding for XML header. Default is 'UTF-8'.
no_simple
TODO not implemented. Reference to array of tags, that can't by simple. Default is [].
output_handler
Handler for print output strings. Must be a GLOB. Default is undef.
preserved
TODO not implemented. Default value is reference to blank array.
set_indent
Set indent flag. Default is 0.
skip_bad_tags
Skip bad tags. Default value is 0.
xml_version
XML version for XML header. Default is "1.1".
finalize()
Finalize Tags output. Automaticly puts end of all opened tags. Returns undef.
flush($reset_flag)
Flush tags in object. If defined 'output_handler' flush to its. Or return code. If enabled $reset_flag, then resets internal variables via reset method.
open_tags()
Return array of opened tags.
put(@data)
Put tags code in tags format. Returns undef.
reset()
Resets internal variables. Returns undef.
TODO
use strict; use warnings; use Tags::Output::LibXML; # Object. my $tags = Tags::Output::LibXML->new; # Put data. $tags->put( ['b', 'text'], ['d', 'data'], ['e', 'text'], ); # Print. print $tags->flush."\n"; # Output: # <?xml version="1.1" encoding="UTF-8"?> # <text>data</text>
use strict; use warnings; use Encode; use Tags::Output::LibXML; # Object. my $tags = Tags::Output::LibXML->new( 'data_callback' => sub { my $data_ar = shift; foreach my $data (@{$data_ar}) { $data = encode_utf8($data); } return; }, ); # Data in characters. my $data = decode_utf8('řčěšřšč'); # Put data. $tags->put( ['b', 'text'], ['d', $data], ['e', 'text'], ); # Print. print $tags->flush."\n"; # Output: # <?xml version="1.1" encoding="UTF-8"?> # <text>řčěšřšč</text>
Error::Pure, Readonly, Tags::Output, XML::LibXML.
Structure oriented SGML/XML/HTML/etc. elements manipulation.
Base class for Tags::Output::*.
Install the Tags modules.
https://github.com/michal-josef-spacek/Tags-Output-LibXML
Michal Josef Špaček skim@cpan.org
http://skim.cz
© 2011-2020 Michal Josef Špaček
BSD 2-Clause License
0.03
To install Tags::Output::LibXML, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tags::Output::LibXML
CPAN shell
perl -MCPAN -e shell install Tags::Output::LibXML
For more information on module installation, please visit the detailed CPAN module installation guide.