Query: xml::libxml::lazybuilder
OS: debian
Section: 3pm
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
XML::LibXML::LazyBuilder(3pm) User Contributed Perl Documentation XML::LibXML::LazyBuilder(3pm)NAMEXML::LibXML::LazyBuilder - easy and lazy way to create XML document for XML::LibXMLSYNOPSISuse 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"))))); }DESCRIPTIONYou can describe XML documents like simple function call instead of using createElement, appendChild, etc... FUNCTIONS E E "tagname", \%attr, @children Creats 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, $enc Generates "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: <?xml version="1.0" encoding="utf-8"?> <A at1="val1" at2="val2"><B><C/><D>Content of D</D></B><E><F>Content of F</F><G/></E></A>SEE ALSOXML::LibXMLAUTHORToru Hisai, <toru@torus.jp>COPYRIGHT AND LICENSECopyright (C) 2008 by Toru Hisai This 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. perl v5.12.3 2008-11-10 XML::LibXML::LazyBuilder(3pm)
Related Man Pages |
---|
xml::libxml::pi(3) - osx |
xml::libxml::pi(3) - mojave |
xml::libxml::pi(3) - suse |
xml::libxml::relaxng(3) - osx |
xml::libxml::lazybuilder(3pm) - debian |
Similar Topics in the Unix Linux Community |
---|
Question? |
Substring HELP! |
XWCM 1.0.0 (Default branch) |
Perl XML::DOM: How to test if element exists? |
XML to Table conversion |