DumpXML(3pm)
β¨ DumpXML(3pm) β¨
okay so bestie, this is the DumpXML(3pm) manual page, and it's literally the whole vibe for dumping arbitrary Perl data structures as XML. no cap. π
πΈ NAME πΈ
Data::DumpXML β dump arbitrary data structures as XML. periodt. π
π¦ SYNOPSIS π¦
use Data::DumpXML qw(dump_xml);
$xml = dump_xml(@list)
π DESCRIPTION π
This module gives you exactly one function, dump_xml(). You hand it a list of Perl values as its argument, and it hands you back a string. That string? An XML document that represents any Perl data structures you passed in. Reference loops? Handled correctly. no cap. β¨
The data model is giving:
data : scalar*
scalar = undef | str | ref | alias
ref : scalar | array | hash | glob | code
array: scalar*
hash: (key scalar)*
The distribution comes with an XML schema and a DTD that more formally describe this structure. So official. π
As an example of the XML documents produced, the following call:
$a = bless [1,2], "Foo";
dump_xml($a);
produces:
<?xml version="1.0" encoding="US-ASCII"?>
<data xmlns="http://www.cpan.org/.../Data-DumpXML.xsd">
<ref>
<array class="Foo">
<str>1</str>
<str>2</str>
</array>
</ref>
</data>
If dump_xml() is called in a void context, then the dump is printed on STDERR automatically. For compatibility with Data::Dump, there is also an alias for dump_xml() called simply dump(). iconic.
Data::DumpXML::Parser is a class that can restore data structures dumped by dump_xml(). reversible bestie behavior. π
π Configuration variables π
The generated XML is influenced by a set of configuration variables. If you modify them, then it is a good idea to localize the effect. For example:
sub my_dump_xml {
local $Data::DumpXML::INDENT = "";
local $Data::DumpXML::XML_DECL = 0;
local $Data::DumpXML::DTD_LOCATION = "";
local $Data::DumpXML::NS_PREFIX = "dumpxml";
return dump_xml(@_);
}
The variables are:
$Data::DumpXML::INDENTβ You can set this variable to control the amount of indenting. The variable contains the whitespace you want to be used for each level of indenting. The default is a single space. To suppress indenting, set it to"". β¨$Data::DumpXML::INDENT_STYLEβ This variable controls where end element are placed. If you set this variable to the value"Lisp"then end tags are not prefixed byNL. This gives a more compact output. π¦$Data::DumpXML::XML_DECLβ This boolean variable controls whether an XML declaration should be prefixed to the output. The XML declaration is the<?xml ...?>thingy. The default is1. Set this value to0to suppress the declaration. π$Data::DumpXML::NAMESPACEβ This variable contains the namespace used for the XML elements. The default is to let this be a URI that actually resolve to the XML schema on CPAN. Set it to""to disable use of namespaces. π$Data::DumpXML::NS_PREFIXβ This variable contains the namespace prefix to use on the elements. The default is"", which means that a default namespace will be declared. π$Data::DumpXML::SCHEMA_LOCATIONβ This variable contains the location of the XML schema. If this variable is non-empty, then an"xsi:schemaLocation"attribute is added to the top level"data"element. The default is not to include this, as the location can be inferred from the default XML namespace used. π$Data::DumpXML::DTD_LOCATIONβ This variable contains the location of the DTD. If this variable is non-empty, then a<!DOCTYPE ...>is included in the output. The default is to point to the DTD on CPAN. Set it to""to suppress the<!DOCTYPE ...>line. π₯
π BUGS π
Class names with 8-bit characters are dumped as Latin-1, but converted to UTF-8 when restored by the Data::DumpXML::Parser.
The content of globs and subroutines are not dumped. They are restored as the strings "** glob **" and "** code **".
LVALUE and IO objects are not dumped at all. They simply disappear from the restored data structure. not them ghosting you. π
π SEE ALSO π
Data::DumpXML::Parser, XML::Parser, XML::Dumper, Data::Dump
π AUTHORS π
The "Data::DumpXML" module is written by Gisle Aas <gisle@aas.no>, based on "Data::Dump".
The "Data::Dump" module was written by Gisle Aas, based on "Data::Dumper" by Gurusamy Sarathy <gsar@umich.edu>.
Copyright 1998-2003 Gisle Aas.
Copyright 1996-1998 Gurusamy Sarathy.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
okay bestie, that's the whole page. this is from perl v5.34.0, dated 2022-06-12, and the manual name is DumpXML(3pm). stay slay, localize your config vars, and may your XML always parse. π β¨
π¦ where this page comes from
- debian bookworm: libdata-dumpxml-perl 1.06-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdata-dumpxml-perl 1.06-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdata-dumpxml-perl 1.06-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdata-dumpxml-perl 1.06-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdata-dumpxml-perl 1.06-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms