{
    "mode": "perldoc",
    "parameter": "XML::CSV",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ACSV/json",
    "generated": "2026-05-30T16:08:14Z",
    "synopsis": "use XML::CSV;\n$csvobj = XML::CSV->new();\n$csvobj = XML::CSV->new(\\%attr);\n$status = $csvobj->parsedoc(filename);\n$status = $csvobj->parsedoc(filename, \\%attr);\n$csvobj->declarexml(\\%attr);\n$csvobj->declaredoctype(\\%attr);\n$csvobj->printxml(filename, \\%attr);",
    "sections": {
        "NAME": {
            "content": "XML::CSV - Perl extension converting CSV files to XML\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use XML::CSV;\n$csvobj = XML::CSV->new();\n$csvobj = XML::CSV->new(\\%attr);\n\n$status = $csvobj->parsedoc(filename);\n$status = $csvobj->parsedoc(filename, \\%attr);\n\n$csvobj->declarexml(\\%attr);\n$csvobj->declaredoctype(\\%attr);\n\n$csvobj->printxml(filename, \\%attr);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "XML::CSV is a new module in is going to be upgraded very often as my\ntime permits. For the time being it uses CSVXS module object default\nvalues to parse the (*.csv) document and then creates a perl data\nstructure with xml tags names and data. At this point it does not allow\nfor a write as you parse interface but is the first upgrade for the next\nrelease. I will also allow more access to the data structures and more\ndocumentation. I will also put in more support for XML, since currently\nit only allows a simple XML structure. Currently you can modify the tag\nstructure to allow for attributes. No DTD support is currently\navailable, but will be implemented in a soon coming release. As the\nmodule will provide both: object and event interfaces, it will be used\nupon individual needs, system resources, and required performance.\nOfcourse the DOM implementation takes up more resources and in some\ninstances timing, it's the easiest to use.\n\nATTRIBUTES new()\nerrorout - Turn on the error handling which will die on all errors and\nassign the error message to $XML::CSV::csvxmlerror.\n\ncolumnheadings - Specifies the column heading to use. Passed as an\narray reference. Can be used as a supplement to using the first column\nin the file as the XML tag names. Since XML::CSV does not require you to\nparse the CSV file, you can provide your own data structure to parse.\n\ncolumndata - Specifies the CSV data in a two dimensional array. Passed\nas an array reference.\n\ncsvxs - Specifies the CSVXS object to use. This is used to create\ncustom CSVXS object and override the default one created by XML::CSV.\n\nATTRIBUTES parsedoc()\nheadings - Specifies the number of rows to use as tag names. Defaults to\n0. Ex. {headings => 1} (This will use the first row of data as xml tags)\n\nsubchar - Specifies the character with which the illegal tag characters\nwill be replaced with. Defaults to undef meaning no substitution is\ndone. To eliminate characters use \"\" (empty string) or to replace with\nanother see below. Ex. {subchar => \"\"} or {subchar => \"\"}\n\nATTRIBUTES declarexml()\nversion - Specifies the xml version. Ex. {version => '1.0'}\n\nencoding - Specifies the type of encoding. XML standard defaults\nencoding to 'UTF-8' if notspecifically set. Ex. {encoding =>\n'ISO-88591'}\n\nstandalone - Specifies the the document as standalone (yes|no). If the\ndocument is does not rely on an external DTD, DTD is internal, or the\nexternal DTD does not effect the contents of the document, the\nstandalone attribute should be set to 'yes', otherwise 'no' should be\nused. For more info see XML declaration documentation. Ex. {standalone\n=> 'yes'}\n\nATTRIBUTES declaredoctype()\nsource - Specifies the source of the DTD (SYSTEM|PUBLIC) Ex. {source =>\n'SYSTEM'}\n\nlocation1 - URI to the DTD file. Public ID may be used if source is\nPUBLIC. Ex. {location1 => 'http://www.xmlproj.com/dtd/indexdtd.dtd'} or\n{location1 => '-//Netscape Communications//DTD RSS 0.90//EN'}\n\nlocation2 - Optional second URI. Usually used if the location1 public ID\nis not found by the validating parser. Ex. {location2 =>\n'http://www.xmlproj.com/file.dtd'}\n\nsubset - Any other information that proceedes the DTD declaration.\nUsually includes internal DTD if any. Ex. {subset => 'ELEMENT firstname\n(#PCDATA)>\\n<!ELEMENT lastname (#PCDATA)>'} You can even enterpolate\nthe string with $obj->{columnheadings} to dynamically build the DTD.\nEx. {subset => \"ELEMENT $obj->{columntheadings}[0] (#PCDATA)>\"}\n\nATTRIBUTES printxml()\nfiletag - Specifies the file parent tag. Defaults to \"records\". Ex.\n{filetag => \"filedata\"} (Do not use < and > when specifying)\n\nparenttag - Specifies the record parent tag. Defaults to \"record\". Ex.\n{parenttag => \"recorddata\"} (Do not use < and > when specifying)\n\nformat - Specifies the character to use to indent nodes. Defaults to\n\"\\t\" (tab). Ex. {format => \" \"} or {format => \"\\t\\t\"}\n",
            "subsections": []
        },
        "PUBLIC VARIABLES": {
            "content": "$csvobj->{columnheadings} $csvobj->{columndata}\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "Example #1:\n\nThis is a simple implementation which uses defaults\n\nuse XML::CSV; $csvobj = XML::CSV->new();\n$csvobj->parsedoc(\"infile.csv\", {headings => 1});\n\n$csvobj->printxml(\"out.xml\");\n\nExample #2:\n\nThis example uses a passed headings array reference which is used along\nwith the parsed data.\n\nuse XML::CSV; $csvobj = XML::CSV->new();\n\n$csvobj->{columnheadings} = \\@arrofheadings;\n\n$csvobj->parsedoc(\"infile.csv\"); $csvobj->printxml(\"out.xml\",\n{format => \" \", filetag = \"xmlfile\", parenttag => \"record\"});\n\nExample #3:\n\nFirst it passes a reference to a array with column headings and then a\nreference to two dimensional array of data where the first index\nrepresents the row number and the second column number. We also pass a\ncustom Text::CSVXS object to overwrite the default object. This is\nuseful for creating your own CSVXS object's args before using the\nparsedoc() method. See 'perldoc Text::CSVXS' for different new()\nattributes.\n\nuse XML::CSV;\n\n$defaultobjxs = Text::CSVXS->new({quotechar => '\"'}); $csvobj =\nXML::CSV->new({csvxs => $defaultobjxs}); $csvobj->{columnheadings}\n= \\@arrofheadings;\n\n$csvobj->{columndata} = \\@arrofdata;\n\n$csvobj->printxml(\"out.xml\");\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Ilya Sterin, isterin@mail.com\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Text::CSVXS\n",
            "subsections": []
        }
    },
    "summary": "XML::CSV - Perl extension converting CSV files to XML",
    "flags": [],
    "examples": [
        "Example #1:",
        "This is a simple implementation which uses defaults",
        "use XML::CSV; $csvobj = XML::CSV->new();",
        "$csvobj->parsedoc(\"infile.csv\", {headings => 1});",
        "$csvobj->printxml(\"out.xml\");",
        "Example #2:",
        "This example uses a passed headings array reference which is used along",
        "with the parsed data.",
        "use XML::CSV; $csvobj = XML::CSV->new();",
        "$csvobj->{columnheadings} = \\@arrofheadings;",
        "$csvobj->parsedoc(\"infile.csv\"); $csvobj->printxml(\"out.xml\",",
        "{format => \" \", filetag = \"xmlfile\", parenttag => \"record\"});",
        "Example #3:",
        "First it passes a reference to a array with column headings and then a",
        "reference to two dimensional array of data where the first index",
        "represents the row number and the second column number. We also pass a",
        "custom Text::CSVXS object to overwrite the default object. This is",
        "useful for creating your own CSVXS object's args before using the",
        "parsedoc() method. See 'perldoc Text::CSVXS' for different new()",
        "attributes.",
        "use XML::CSV;",
        "$defaultobjxs = Text::CSVXS->new({quotechar => '\"'}); $csvobj =",
        "XML::CSV->new({csvxs => $defaultobjxs}); $csvobj->{columnheadings}",
        "= \\@arrofheadings;",
        "$csvobj->{columndata} = \\@arrofdata;",
        "$csvobj->printxml(\"out.xml\");"
    ],
    "see_also": []
}