{
    "mode": "perldoc",
    "parameter": "XML::CSV",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ACSV/json",
    "generated": "2026-07-05T04:39:18Z",
    "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 time permits. For the time\nbeing it uses CSVXS module object default values to parse the (*.csv) document and then creates\na perl data structure with xml tags names and data. At this point it does not allow for a write\nas you parse interface but is the first upgrade for the next release. I will also allow more\naccess to the data structures and more documentation. I will also put in more support for XML,\nsince currently it only allows a simple XML structure. Currently you can modify the tag\nstructure to allow for attributes. No DTD support is currently available, but will be\nimplemented in a soon coming release. As the module will provide both: object and event\ninterfaces, it will be used upon individual needs, system resources, and required performance.\nOfcourse the DOM implementation takes up more resources and in some instances timing, it's the\neasiest to use.\n\nATTRIBUTES new()\nerrorout - Turn on the error handling which will die on all errors and assign the error message\nto $XML::CSV::csvxmlerror.\n\ncolumnheadings - Specifies the column heading to use. Passed as an array reference. Can be used\nas a supplement to using the first column in the file as the XML tag names. Since XML::CSV does\nnot require you to parse the CSV file, you can provide your own data structure to parse.\n\ncolumndata - Specifies the CSV data in a two dimensional array. Passed as an array reference.\n\ncsvxs - Specifies the CSVXS object to use. This is used to create custom CSVXS object and\noverride the default one created by XML::CSV.\n\nATTRIBUTES parsedoc()\nheadings - Specifies the number of rows to use as tag names. Defaults to 0. Ex. {headings => 1}\n(This will use the first row of data as xml tags)\n\nsubchar - Specifies the character with which the illegal tag characters will be replaced with.\nDefaults to undef meaning no substitution is done. To eliminate characters use \"\" (empty string)\nor to replace with another 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 encoding to 'UTF-8' if\nnotspecifically set. Ex. {encoding => 'ISO-88591'}\n\nstandalone - Specifies the the document as standalone (yes|no). If the document is does not rely\non an external DTD, DTD is internal, or the external DTD does not effect the contents of the\ndocument, the standalone attribute should be set to 'yes', otherwise 'no' should be used. For\nmore info see XML declaration documentation. Ex. {standalone => 'yes'}\n\nATTRIBUTES declaredoctype()\nsource - Specifies the source of the DTD (SYSTEM|PUBLIC) Ex. {source => 'SYSTEM'}\n\nlocation1 - URI to the DTD file. Public ID may be used if source is PUBLIC. Ex. {location1 =>\n'http://www.xmlproj.com/dtd/indexdtd.dtd'} or {location1 => '-//Netscape Communications//DTD\nRSS 0.90//EN'}\n\nlocation2 - Optional second URI. Usually used if the location1 public ID is not found by the\nvalidating parser. Ex. {location2 => 'http://www.xmlproj.com/file.dtd'}\n\nsubset - Any other information that proceedes the DTD declaration. Usually includes internal DTD\nif any. Ex. {subset => 'ELEMENT firstname (#PCDATA)>\\n<!ELEMENT lastname (#PCDATA)>'} You can\neven enterpolate the string with $obj->{columnheadings} to dynamically build the DTD. Ex.\n{subset => \"ELEMENT $obj->{columntheadings}[0] (#PCDATA)>\"}\n\nATTRIBUTES printxml()\nfiletag - Specifies the file parent tag. Defaults to \"records\". Ex. {filetag => \"filedata\"}\n(Do not use < and > when specifying)\n\nparenttag - Specifies the record parent tag. Defaults to \"record\". Ex. {parenttag =>\n\"recorddata\"} (Do not use < and > when specifying)\n\nformat - Specifies the character to use to indent nodes. Defaults to \"\\t\" (tab). Ex. {format =>\n\" \"} 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(); $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 with 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\", {format => \" \", filetag =\n\"xmlfile\", parenttag => \"record\"});\n\nExample #3:\n\nFirst it passes a reference to a array with column headings and then a reference to two\ndimensional array of data where the first index represents the row number and the second column\nnumber. We also pass a custom Text::CSVXS object to overwrite the default object. This is\nuseful for creating your own CSVXS object's args before using the parsedoc() method. See\n'perldoc Text::CSVXS' for different new() attributes.\n\nuse XML::CSV;\n\n$defaultobjxs = Text::CSVXS->new({quotechar => '\"'}); $csvobj = XML::CSV->new({csvxs =>\n$defaultobjxs}); $csvobj->{columnheadings} = \\@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": []
}