CSV to XML Converter

Updated: Jan 22, 2019

CSV to XML Converter is used to convert CSV data or file into XML. You can choose whether to write the values as XML attributes or as text inside the record elements. The XML elements generated can also be named as per your choice. The input CSV can also have double quote characters surrounding the values.



Input: Paste CSV content below



Settings

Background Information

CSV is an old & very popular format for storing tabular data. It has been used in the desktop as well as mainframe. It is a simple & compact format that works really well for tabular data and so is still in use today.

Extensible Markup Language (XML) is a widely used language that was once the de facto standard for data interchange between applications. Since the advent of JSON, however, it has lost the advantage to the more simple nature of JSON. Nevertheless, XML is still used by applications and SOAP based web services

Settings Explained

  • First Row Is Header

    If this option is selected the first row of your comma separated file is assumed to be the header. The names of the properties are generated using the field values in the first row. If the option is not selected the property names are generated automatically using a numeric pattern: column 1, column 2, column 3, etc. In the latter case the first row is interpreted as raw data.

    First Row is Header On

    <?xml version="1.0" encoding="utf-8"?>
    <Records>
      <Record Name="Robin Hood" Department="" Manager="" Salary="200" />
    </Records>

    First Row is Header Off

    <?xml version="1.0" encoding="utf-8"?>
    <Records>
      <Record Column1="Name" Column2="Department" Column3="Manager" Column4="Salary" />
      <Record Column1="Robin Hood" Column2="" Column3="" Column4="200" />
    </Records>

  • Delimiter

    The delimiter in the input CSV is specified here. In most cases the default setting Auto Detect works fine. But, in really small CSV data with delimiters also occurring as literals, the auto detection logic might not choose the correct delimiter. In such a scenario, the delimiter can be manually specified. Following are the choices for delimiters:-

    • Comma
    • Tab
    • Space
    • Pipe
    • Semi-Colon

  • Root Element Name

    This is the name of the root element of the output XML under which the record/row nodes are created.

    Root Element: People

    <?xml version="1.0" encoding="utf-8"?>
    <People>
      <Record Name="John Doe" Age="69" />
      <Record Name="Jane Doe" Age="65" />
    </People>

    Root Element: Root

    <?xml version="1.0" encoding="utf-8"?>
    <Root>
      <Record Name="John Doe" Age="69" />
      <Record Name="Jane Doe" Age="65" />
    </Root>

  • Record Element Name

    This is the name of all the record/row elements created in the output XML.

    Record Element: Person

    <?xml version="1.0" encoding="utf-8"?>
    <Root>
      <Person Name="John Doe" Age="69" />
      <Person Name="Jane Doe" Age="65" />
    </Root>

    Record Element: Record

    <?xml version="1.0" encoding="utf-8"?>
    <Root>
      <Record Name="John Doe" Age="69" />
      <Record Name="Jane Doe" Age="65" />
    </Root>

  • Indent

    This setting governs whether or not the output is indented. The indented output is easier for humans to comprehend. On the other hand, a non-indented output is compact & smaller in size (best for transmission).

    Indentation On

    <?xml version="1.0" encoding="utf-8"?>
    <Root>
      <Record Name="John Doe" Age="69" />
      <Record Name="Jane Doe" Age="65" />
    </Root>

    Indentation Off

    <?xml version="1.0" encoding="utf-8" ?><Root><Record Name="John Doe" Age="69" /><Record Name="Jane Doe" Age="65" /></Root>

  • Attribute Values

    This setting governs how the values are written in the output XML. When turned on, the values are written as XML attributes of the record elements. When turned off, the values are written as text nodes inside the record elements.

    Attribute Values On

    <?xml version="1.0" encoding="utf-8"?>
    <People>
      <Person Name="John Doe" Age="69" />
      <Person Name="Jane Doe" Age="65" />
    </People>

    Attribute Values Off

    <?xml version="1.0" encoding="utf-8"?>
    <People>
      <Person>
        <Name>John Doe</Name>
        <Age>69</Age>
      </Person>
      <Person>
        <Name>Jane Doe</Name>
        <Age>65</Age>
      </Person>
    </People>

 

You may also like...

CSV to JSON Converter

Convert CSV data into JSON. Choose whether property names are auto generated or taken from the header

View Tool

GUID Converter

Convert GUID to/from Hex, Int, Base64 and standard format

View Tool

HTML Table to CSV Converter

Convert HTML table to CSV by extracting rows from it

View Tool

Comments 0



History

Mar 7, 2018
Delimiter & First Row is Header Parameters
Aug 25, 2017
Tool Launched