Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/doriantaylor/p5-xml-libxml-lazybuilder
TORU's XML::LibXML::LazyBuilder, now with namespaces
https://github.com/doriantaylor/p5-xml-libxml-lazybuilder
Last synced: 24 days ago
JSON representation
TORU's XML::LibXML::LazyBuilder, now with namespaces
- Host: GitHub
- URL: https://github.com/doriantaylor/p5-xml-libxml-lazybuilder
- Owner: doriantaylor
- Created: 2012-06-25T01:55:08.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-06-25T02:01:05.000Z (over 12 years ago)
- Last Synced: 2023-03-12T10:11:35.704Z (almost 2 years ago)
- Language: Perl
- Size: 97.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
Awesome Lists containing this project
README
NAME
XML::LibXML::LazyBuilder - easy and lazy way to create XML document for
XML::LibXMLSYNOPSIS
use XML::LibXML::LazyBuilder;{
package XML::LibXML::LazyBuilder;
$d = DOM (E A => {at1 => "val1", at2 => "val2"},
((E B => {}, ((E "C"),
(E D => {}, "Content of D"))),
(E E => {}, ((E F => {}, "Content of F"),
(E "G")))));
}DESCRIPTION
You can describe XML documents like simple function call instead of
using createElement, appendChild, etc...FUNCTIONS
E
E "tagname", \%attr, @childrenCreats CODEREF that generates "XML::LibXML::Element" which tag name
is given by first argument. Rest arguments are list of text content
or child element created by "E" (so you can nest "E").Since the output of this function is CODEREF, the creation of actual
"XML::LibXML::Element" object will be delayed until "DOM" function
is called.DOM
DOM \&docroot, $var, $encGenerates "XML::LibXML::Document" object actually. First argument is
a CODEREF created by "E" function. $var is version number of XML
docuemnt, "1.0" by default. $enc is encoding, "utf-8" by default.EXPORT
None by default.:all
Exports "E" and "DOM".EXAMPLES
I recommend to use "package" statement in a small scope so that you can
use short function name and avoid to pollute global name space.my $d;
{
package XML::LibXML::LazyBuilder;
$d = DOM (E A => {at1 => "val1", at2 => "val2"},
((E B => {}, ((E "C"),
(E D => {}, "Content of D"))),
(E E => {}, ((E F => {}, "Content of F"),
(E "G")))));
}Then, "$d->toString" will generate XML like this:
SEE ALSO
XML::LibXMLAUTHOR
Toru Hisai,COPYRIGHT AND LICENSE
Copyright (C) 2008 by Toru HisaiThis library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself, either Perl version 5.10.0 or, at
your option, any later version of Perl 5 you may have available.