String(3pm) User Contributed Perl Documentation String(3pm)NAME
XML::Writer::String - Capture output from XML::Writer.
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();
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.
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.
AUTHOR
Simon Oliver <simon.oliver@umist.ac.uk>
COPYRIGHT
Copyright (C) 2002 Simon Oliver
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
XML::Writer, IO::Handle, IO::Scalar
perl v5.14.2 2002-03-06 String(3pm)
Check Out this Related Man Page
XML::Writer::Simple(3pm) User Contributed Perl Documentation XML::Writer::Simple(3pm)NAME
XML::Writer::Simple - Create XML files easily!
SYNOPSIS
use XML::Writer::Simple dtd => "file.dtd";
print xml_header(encoding => 'iso-8859-1');
print para("foo",b("bar"),"zbr");
# if you want CGI but you do not want CGI :)
use XML::Writer::Simple ':html';
USAGE
This module takes some ideas from CGI to make easier the life for those who need to generated XML code. You can use the module in three
flavours (or combine them):
tags
When importing the module you can specify the tags you will be using:
use XML::Writer::Simple tags => [qw/p b i tt/];
print p("Hey, ",b("you"),"! ", i("Yes ", b("you")));
that will generate
<p>Hey <b>you</b>! <i>Yes <b>you</b></i></p>
dtd You can supply a DTD, that will be analyzed, and the tags used:
use XML::Writer::Simple dtd => "tmx.dtd";
print tu(seg("foo"),seg("bar"));
xml You can supply an XML (or a reference to a list of XML files). They will be parsed, and the tags used:
use XML::Writer::Simple xml => "foo.xml";
print foo("bar");
partial
You can supply an 'partial' key, to generate prototypes for partial tags construction. For instance:
use XML::Writer::Simple tags => qw/foo bar/, partial => 1;
print start_foo;
print ...
print end_foo;
You can also use tagsets, where sets of tags from a well known format are imported. For example, to use HTML:
use XML::Writer::Simple ':html';
EXPORT
This module export one function for each element at the dtd or xml file you are using. See below for details.
FUNCTIONS
import
Used when you 'use' the module, should not be used directly.
xml_header
This function returns the xml header string, without encoding definition, with a trailing new line. Default XML encoding should be UTF-8,
by the way.
You can force an encoding passing it as argument:
print xml_header(encoding=>'iso-8859-1');
powertag
Used to specify a powertag. For instance:
powertag("ul","li");
ul_li([qw/foo bar zbr ugh/]);
will generate
<ul>
<li>foo</li>
<li>bar</li>
<li>zbr</li>
<li>ugh</li>
</ul>
You can also supply this information when loading the module, with
use XML::Writer::Simple powertags=>["ul_li","ol_li"];
Powertags support three level tags as well:
use XML::Writer::Simple powertags=>["table_tr_td"];
print table_tr_td(['a','b','c'],['d','e','f']);
AUTHOR
Alberto Simo~es, "<ambs@cpan.org>"
BUGS
Please report any bugs or feature requests to "bug-xml-writer-simple@rt.cpan.org", or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=XML-Writer-Simple <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=XML-Writer-Simple>. I
will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
COPYRIGHT AND LICENSE
Copyright 1999-2012 Project Natura.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2012-06-05 XML::Writer::Simple(3pm)