man > Data::DumpXML(3pm)

๐Ÿ“› NAME

Data::DumpXML โ€” Dump arbitrary data structures as XML

๐Ÿš€ Quick Reference

Use CaseCommandDescription
๐Ÿ”ง Basic dump$xml = dump_xml(@data)Serialize any Perl data structure to XML
๐Ÿ–จ๏ธ Dump to STDERRdump_xml(@data)Void context โ€” prints XML to STDERR automatically
๐Ÿ“ Control indentlocal $Data::DumpXML::INDENT = " "Set whitespace per nesting level (default: one space)
๐Ÿ—œ๏ธ Compact outputlocal $Data::DumpXML::INDENT_STYLE = "Lisp"Prevents newlines before end tags
๐Ÿšซ No XML decllocal $Data::DumpXML::XML_DECL = 0Suppress the <?xml ...?> declaration
๐ŸŒ No namespacelocal $Data::DumpXML::NAMESPACE = ""Disable XML namespace usage
๐Ÿ“„ No DTDlocal $Data::DumpXML::DTD_LOCATION = ""Suppress <!DOCTYPE ...> line
๐Ÿ”„ Restore datause Data::DumpXML::ParserParse dumped XML back into Perl structures

๐Ÿ“‹ SYNOPSIS

use Data::DumpXML qw(dump_xml);
$xml = dump_xml(@list);

๐Ÿ“– DESCRIPTION

This module provides a single function called dump_xml() that takes a list of Perl values as its argument and produces a string as its result. The string returned is an XML document that represents any Perl data structures passed to the function. Reference loops are handled correctly. ๐Ÿ”„

๐Ÿ“Š The following data model is used:

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. ๐Ÿ“

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().

Data::DumpXML::Parser is a class that can restore data structures dumped by dump_xml(). ๐Ÿ”„

โš™๏ธ 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 the variable $Data::DumpXML::INDENT 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 elements are placed. If you set this variable to the value "Lisp" then end tags are not prefixed by NL. 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 is 1. Set this value to 0 to 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 resolves 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

๐Ÿ”— SEE ALSO

Data::DumpXML::Parser, XML::Parser, XML::Dumper, Data::Dump

๐Ÿ‘ค AUTHORS

The Data::DumpXML module is written by Gisle Aas <gisle AT aas.no>, based on Data::Dump. โœ๏ธ

The Data::Dump module was written by Gisle Aas, based on Data::Dumper by Gurusamy Sarathy <gsar AT 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. ๐Ÿ†“

Data::DumpXML(3pm)
๐Ÿ“› NAME ๐Ÿš€ Quick Reference ๐Ÿ“‹ SYNOPSIS ๐Ÿ“– DESCRIPTION
โš™๏ธ Configuration variables
๐Ÿ› BUGS ๐Ÿ”— SEE ALSO ๐Ÿ‘ค AUTHORS

Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-02 12:21 @216.73.217.9
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^