XML::G...or::DOM(3pm)

✨ NAME ✨

XML::Generator::DOM β€” bestie, it's the XML::Generator subclass that hands you back DOM trees instead of boring old strings. πŸ’–


🌸 SYNOPSIS 🌸

okay so literally here's the whole vibe:

use XML::Generator::DOM;

my $dg  = XML::Generator::DOM->new();
my $doc = $dg->xml($dg->xmlcmnt("Test document."),
                   $dg->foo({'baz' => 'bam'}, 42));
print $doc->toString;

and that yields:

<?xml version="1.0" standalone="yes"?>
<!--Test document-->
<foo baz="bam">42</foo>

ate. no crumbs. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

XML::Generator::DOM subclasses XML::Generator so it can produce DOM trees instead of strings (go peek at XML::Generator and XML::DOM if you wanna know more). ⚠️ heads up though: this module is still experimental and its semantics might change. so like. don't get too attached to the details, iykyk.

basically, tag methods return XML::DOM::DocumentFragment objects. where do those come from? either from a DOM document you pass into the constructor, or from a default document that XML::Generator::DOM just automatically constructs for you. main character energy, honestly. πŸ‘‘

calling the xml() method returns this automatically constructed document and causes a fresh one to be constructed for future tag method calls. but if you passed in your own document, you may not call the xml() method. periodt.

below, we just note the remaining differences in semantics between XML::Generator methods and XML::Generator::DOM methods. πŸ“


πŸ’œ LICENSE πŸ’œ

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. 🫢


πŸŽ€ CONSTRUCTOR πŸŽ€

these configuration options get accepted but have no effect on the semantics of the returned object:

  • escape
  • pretty
  • conformance
  • empty

like they're there, they're just... vibing. πŸ™ˆ


⭐ TAG METHODS ⭐

so from here on out, tag method semantics are somewhat different for this module compared to XML::Generator. the primary difference is that tag methods return XML::DOM::DocumentFragment objects. namespace and attribute processing stays the same, but the remaining arguments to tag methods must either be text or other XML::DOM::DocumentFragment objects.

and ngl β€” no escape processing, no syntax checking, no output control is done. it's all left up to XML::DOM. 😌


🌈 SPECIAL TAGS 🌈

every special tag is available by default with XML::Generator::DOM β€” you do not need to use 'conformance' => 'strict'. slay.

πŸ’« xmlpi(@args)

arguments will simply be concatenated and passed as the data to the XML::DOM::ProcessingInstruction object that is returned. easy peasy. ✨

πŸ’« xmlcmnt

escaping of '--' is done by XML::DOM::Comment, which replaces both hyphens with '&#45;'. an XML::DOM::Comment object is returned.

πŸ’« xmldecl

returns an XML::DOM::XMLDecl object. respects 'version', 'encoding' and 'dtd' settings in the object. πŸŽ€

πŸ’« xmldecl

returns an XML::DOM::DocumentType object.

yes bestie, it's listed twice with the same name β€” that's literally what the page says, i'm just the messenger πŸ’€

πŸ’« xmlcdata

returns an XML::DOM::CDATASection object. 🌸

πŸ’« xml

as described above, xml() can only be used when dom_document was not set in the object. the automatically created document will have its XML Declaration set, and the arguments to xml() will be appended to it. then a new DOM document is automatically generated and the old one is returned.

this is the only way to get a DOM document from this module. no cap. πŸ”₯


perl v5.36.0 Β· 2023-06-11 Β· User Contributed Perl Documentation

okay that's the whole page, love u, go build some DOM trees πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from