๐ŸŒ
Reddit
reddit.com โ€บ r/codinghelp โ€บ converting csv file to xml
r/CodingHelp on Reddit: Converting CSV file to XML
September 8, 2024 -

I don't know if this is the right place to post this, but I'm looking for someone who can create a process to convert a daily csv file to xml that can be imported into our billing software.

I'm just looking for a way to find someone to pay to get this set up for me (the company I work for). I've tried searching and have come up empty, so am reaching out to reddit where I get all of my questions answered!

To sum up, I'm looking for where I would search to find someone to write a program / process for me to use to convert a csv file into xml to be able to be imported into a billing software program.

Thanks!

Discussions

Convert XML to (meaningful) CSV
There's a lot of ways. These two would probably be the easiest, assuming the data format stays the same. XSL: https://askubuntu.com/questions/174143/convert-xml-to-csv-shell-command-line Database: Import data into the db then export back out in chosen format. https://stackoverflow.com/questions/19007884/import-xml-files-to-postgresql https://stackoverflow.com/questions/47812771/exporting-postgres-database-data-to-xml CSV is trivial with postgresql https://gist.github.com/nepsilon/f2937fe10fe8b0efc0cc More on reddit.com
๐ŸŒ r/sysadmin
12
4
December 5, 2019
Conversion of CSV to XML with JAVA - Stack Overflow
I have a set of CSV data to be converted to XML. The codes look OK but the output isn't perfect enough. It omits some columns because they have no value and produces a long line of XML data instead... More on stackoverflow.com
๐ŸŒ stackoverflow.com
XML Parts List convert to CSV?
If it doesn't work with a converter, use rebrickable More on reddit.com
๐ŸŒ r/lepin
4
1
June 12, 2024
Looking for easy ways to convert different kinds of Data formats to CSVs
๐ŸŒ r/ecommerce
21
9
December 1, 2024
๐ŸŒ
Site24x7
site24x7.com โ€บ tools โ€บ csv-to-xml.html
CSV to XML Converter: Site24x7 Tools
Online tool for converting CSV data to XML data. Try it for free!
๐ŸŒ
Online XML Tools
onlinexmltools.com โ€บ convert-csv-to-xml
Convert CSV to XML - Online XML Tools
Free online CSV to XML converter. Just paste your CSV in the input form below and it will automatically get converted to XML. Paste CSV, get XML. There are no ads, popups or nonsense, just an awesome CSV to XML transformer.
๐ŸŒ
ApyHub
apyhub.com โ€บ home
Convert CSV to XML API
ApyHub: The API marketplace for developers and AI agents to discover, consume secure, compliant APIs. Simplify integration and accelerate development.
๐ŸŒ
JSON Formatter
jsonformatter.org โ€บ csv-to-xml
CSV to XML Converter Online
CSV to XML Online converter helps to convert CSV data into XML.
Find elsewhere
๐ŸŒ
SysTools Group
systoolsgroup.com โ€บ home โ€บ how to convert xml to csv file? 5 easy methods
Convert XML to CSV Format in Bulk Using the Best Five Methods
October 8, 2025 - A message will appear, and choose the โ€œAs an XML Tableโ€ option. Finally, your XML data will show in table format. Select โ€œSave Asโ€ from the โ€œFileโ€ tab. Choose the โ€œCSVโ€ from the Saving Type list.
๐ŸŒ
Reddit
reddit.com โ€บ r/sysadmin โ€บ convert xml to (meaningful) csv
r/sysadmin on Reddit: Convert XML to (meaningful) CSV
December 5, 2019 -

Hello Redditors. I have a question that has landed on my desk, and which way outside of my practical skill set.

One party has an application that they are heavily invested in. They need to send data - say a list of orders - to another party. The only option for doing so is an XML export file. Let us presume that the vendor for this software is no longer available, so the XML is what it is.

The second party is setup in a similar way. They are used to ingesting lists of orders into their software by way of CSV files, setup in a particular format. Each column has a header and represents a given data set.

The question that I am looking at is how difficult would it be to convert source XML A into CSV B, with the appropriate data fields in the right places. We would need to do this on a regular basis. Keeping in mind that we have little to know development ability on staff, now might we achieve something along these lines? Specifically...

  1. What might this process look like? Excel macro? Web app?

  2. Where might we look to develop this process, whatever it looks like?

  3. Any thoughts at all, given all of this rambling?

Thanks in advance guys.

๐ŸŒ
CodeShack
codeshack.io โ€บ home โ€บ tools โ€บ xml to csv converter
XML to CSV Converter - Free Online Data Tool
Use the buttons to copy the CSV to your clipboard or download it as a `.csv` file. XML (eXtensible Markup Language) is a markup language used to store and transport data. Unlike HTML, XML tags are not predefined; you define your own tags to describe your data.
๐ŸŒ
Quora
quora.com โ€บ How-do-I-convert-a-CSV-file-to-XML
How to convert a CSV file to XML - Quora
Answer (1 of 4): Open an InputStream of the CSV file using either [code ]java.net.URL[/code] or [code ]java.io.File[/code]. In case it is possible, save a copy of the input file before processing e.g. extended with the current timestamp. In case it is required to save the XML output as a file on...
๐ŸŒ
Teleport
goteleport.com โ€บ resources โ€บ tools โ€บ xml-to-csv-converter
XML to CSV Converter | Instantly Transform XML to CSV | Teleport
In this article, weโ€™ll explore the key features of XML and CSV, guide you through the conversion process, and share practical techniques for implementation. Weโ€™ll also address common challenges you might face during implementation and offer effective solutions to integrate these processes smoothly into your data workflows.
๐ŸŒ
ConvertCSV
convertcsv.com โ€บ csv-to-xml.htm
CSV To XML Converter
You have the option of specifying the top-level root name and the XML record name. You can also make each XML name upper or lower case. See also XML to CSV
๐ŸŒ
Migrate Emails
migrateemails.com โ€บ home โ€บ convert xml to csv: easy steps to transform xml files
Convert XML to CSV: Easy Steps to Transform XML Files
October 11, 2025 - In this blog, we will discuss the manual ways and an expert MigrateEmails XML Converter Tool. ... Firstly, CSV is easier to analyze using Excel or Google Sheets.
๐ŸŒ
AskPython
askpython.com โ€บ home โ€บ converting data in csv to xml in python
Converting Data in CSV to XML in Python - AskPython
April 4, 2023 - A Python function will be created which takes the input of the name and path of the CSV file and the name and path of the output XML file. The rest of the work will be done by the code. The driver program will call the function, and then the XML file will be opened in Browser to check the output.
Top answer
1 of 3
2

I'd agree with Kennet.

I simply added

aTransformer .setOutputProperty(OutputKeys.INDENT, "yes");
aTransformer .setOutputProperty(OutputKeys.METHOD, "xml");
aTransformer .setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");

This added a new line between the elements and allowed for indentation.

UPDATED

Let's start with the fact that the file you're presented isn't a CSV (Comma separated value) file and I'll let you worry about that problem...

List<String> headers = new ArrayList<String>(5);

File file = new File("Names2.csv");
BufferedReader reader = null;

try {

    DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder domBuilder = domFactory.newDocumentBuilder();

    Document newDoc = domBuilder.newDocument();
    // Root element
    Element rootElement = newDoc.createElement("XMLCreators");
    newDoc.appendChild(rootElement);

    reader = new BufferedReader(new FileReader(file));
    int line = 0;

    String text = null;
    while ((text = reader.readLine()) != null) {

        StringTokenizer st = new StringTokenizer(text, " ", false);    
        String[] rowValues = new String[st.countTokens()];
        int index = 0;
        while (st.hasMoreTokens()) {
            
            String next = st.nextToken();
            rowValues[index++] = next;
            
        }
    
        //String[] rowValues = text.split(",");

        if (line == 0) { // Header row
            for (String col : rowValues) {
                headers.add(col);
            }
        } else { // Data row
            Element rowElement = newDoc.createElement("row");
            rootElement.appendChild(rowElement);
            for (int col = 0; col < headers.size(); col++) {
                String header = headers.get(col);
                String value = null;

                if (col < rowValues.length) {
                    value = rowValues[col];
                } else {
                    // ?? Default value
                    value = "";
                }

                Element curElement = newDoc.createElement(header);
                curElement.appendChild(newDoc.createTextNode(value));
                rowElement.appendChild(curElement);
            }
        }
        line++;
    }

    ByteArrayOutputStream baos = null;
    OutputStreamWriter osw = null;

    try {
        baos = new ByteArrayOutputStream();
        osw = new OutputStreamWriter(baos);

        TransformerFactory tranFactory = TransformerFactory.newInstance();
        Transformer aTransformer = tranFactory.newTransformer();
        aTransformer.setOutputProperty(OutputKeys.INDENT, "yes");
        aTransformer.setOutputProperty(OutputKeys.METHOD, "xml");
        aTransformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");

        Source src = new DOMSource(newDoc);
        Result result = new StreamResult(osw);
        aTransformer.transform(src, result);

        osw.flush();
        System.out.println(new String(baos.toByteArray()));
    } catch (Exception exp) {
        exp.printStackTrace();
    } finally {
        try {
            osw.close();
        } catch (Exception e) {
        }
        try {
            baos.close();
        } catch (Exception e) {
        }
    }
} catch (Exception e) {
    e.printStackTrace();
}

Now I've used a List instead of a Map here. You'll need to decide how best to approach the missing values problem. Without knowing the structure of the file in advance, this is not going to be a simple solution.

Any way, I end up with

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<XMLCreators>
    <row>
        <Name>chi</Name>
        <Age>23</Age>
        <Sex/>
    </row>
    <row>
        <Name>kay</Name>
        <Age>19</Age>
        <Sex>male</Sex>
    </row>
    <row>
        <Name>John</Name>
        <Age>male</Age>
        <Sex/>
    </row>
</XMLCreators>

Updated with merge

public class XMLCreators {
    // Protected Properties

    protected DocumentBuilderFactory domFactory = null;
    protected DocumentBuilder domBuilder = null;

    public XMLCreators() {
        try {
            domFactory = DocumentBuilderFactory.newInstance();
            domBuilder = domFactory.newDocumentBuilder();
        } catch (FactoryConfigurationError exp) {
            System.err.println(exp.toString());
        } catch (ParserConfigurationException exp) {
            System.err.println(exp.toString());
        } catch (Exception exp) {
            System.err.println(exp.toString());
        }

    }

    public int convertFile(String csvFileName, String xmlFileName,
                    String delimiter) {

        int rowsCount = -1;
        try {
            Document newDoc = domBuilder.newDocument();
            // Root element
            Element rootElement = newDoc.createElement("XMLCreators");
            newDoc.appendChild(rootElement);
            // Read csv file
            BufferedReader csvReader;
            csvReader = new BufferedReader(new FileReader(csvFileName));

//                int fieldCount = 0;
//                String[] csvFields = null;
//                StringTokenizer stringTokenizer = null;
//
//                // Assumes the first line in CSV file is column/field names
//                // The column names are used to name the elements in the XML file,
//                // avoid the use of Space or other characters not suitable for XML element
//                // naming
//
//                String curLine = csvReader.readLine();
//                if (curLine != null) {
//                    // how about other form of csv files?
//                    stringTokenizer = new StringTokenizer(curLine, delimiter);
//                    fieldCount = stringTokenizer.countTokens();
//                    if (fieldCount > 0) {
//                        csvFields = new String[fieldCount];
//                        int i = 0;
//                        while (stringTokenizer.hasMoreElements()) {
//                            csvFields[i++] = String.valueOf(stringTokenizer.nextElement());
//                        }
//                    }
//                }
//
//                // At this point the coulmns are known, now read data by lines
//                while ((curLine = csvReader.readLine()) != null) {
//                    stringTokenizer = new StringTokenizer(curLine, delimiter);
//                    fieldCount = stringTokenizer.countTokens();
//                    if (fieldCount > 0) {
//                        Element rowElement = newDoc.createElement("row");
//                        int i = 0;
//                        while (stringTokenizer.hasMoreElements()) {
//                            try {
//                                String curValue = String.valueOf(stringTokenizer.nextElement());
//                                Element curElement = newDoc.createElement(csvFields[i++]);
//                                curElement.appendChild(newDoc.createTextNode(curValue));
//                                rowElement.appendChild(curElement);
//                            } catch (Exception exp) {
//                            }
//                        }
//                        rootElement.appendChild(rowElement);
//                        rowsCount++;
//                    }
//                }
//                csvReader.close();
//
//                // Save the document to the disk file
//                TransformerFactory tranFactory = TransformerFactory.newInstance();
//                Transformer aTransformer = tranFactory.newTransformer();
//                Source src = new DOMSource(newDoc);
//                Result result = new StreamResult(new File(xmlFileName));
//                aTransformer.transform(src, result);
//                rowsCount++;
            int line = 0;
            List<String> headers = new ArrayList<String>(5);

            String text = null;
            while ((text = csvReader.readLine()) != null) {

                StringTokenizer st = new StringTokenizer(text, delimiter, false);
                String[] rowValues = new String[st.countTokens()];
                int index = 0;
                while (st.hasMoreTokens()) {

                    String next = st.nextToken();
                    rowValues[index++] = next;

                }

                if (line == 0) { // Header row

                    for (String col : rowValues) {
                        headers.add(col);
                    }

                } else { // Data row
                    
                    rowsCount++;

                    Element rowElement = newDoc.createElement("row");
                    rootElement.appendChild(rowElement);
                    for (int col = 0; col < headers.size(); col++) {

                        String header = headers.get(col);
                        String value = null;

                        if (col < rowValues.length) {

                            value = rowValues[col];

                        } else {
                            // ?? Default value
                            value = "";
                        }

                        Element curElement = newDoc.createElement(header);
                        curElement.appendChild(newDoc.createTextNode(value));
                        rowElement.appendChild(curElement);

                    }

                }
                line++;

            }

            ByteArrayOutputStream baos = null;
            OutputStreamWriter osw = null;

            try {

                baos = new ByteArrayOutputStream();
                osw = new OutputStreamWriter(baos);

                TransformerFactory tranFactory = TransformerFactory.newInstance();
                Transformer aTransformer = tranFactory.newTransformer();
                aTransformer.setOutputProperty(OutputKeys.INDENT, "yes");
                aTransformer.setOutputProperty(OutputKeys.METHOD, "xml");
                aTransformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");

                Source src = new DOMSource(newDoc);
                Result result = new StreamResult(osw);
                aTransformer.transform(src, result);

                osw.flush();
                System.out.println(new String(baos.toByteArray()));

            } catch (Exception exp) {
                exp.printStackTrace();
            } finally {
                try {
                    osw.close();
                } catch (Exception e) {
                }
                try {
                    baos.close();
                } catch (Exception e) {
                }
            }

            // Output to console for testing
            // Resultt result = new StreamResult(System.out);

        } catch (IOException exp) {
            System.err.println(exp.toString());
        } catch (Exception exp) {
            System.err.println(exp.toString());
        }
        return rowsCount;
        // "XLM Document has been created" + rowsCount;
    }
}

UPDATED with use of OpenCSV

public class XMLCreators {
    // Protected Properties

    protected DocumentBuilderFactory domFactory = null;
    protected DocumentBuilder domBuilder = null;

    public XMLCreators() {
        try {
            domFactory = DocumentBuilderFactory.newInstance();
            domBuilder = domFactory.newDocumentBuilder();
        } catch (FactoryConfigurationError exp) {
            System.err.println(exp.toString());
        } catch (ParserConfigurationException exp) {
            System.err.println(exp.toString());
        } catch (Exception exp) {
            System.err.println(exp.toString());
        }

    }

    public int convertFile(String csvFileName, String xmlFileName,
                    String delimiter) {

        int rowsCount = -1;
        BufferedReader csvReader;
        try {
            Document newDoc = domBuilder.newDocument();
            // Root element
            Element rootElement = newDoc.createElement("XMLCreators");
            newDoc.appendChild(rootElement);
            // Read csv file
            csvReader = new BufferedReader(new FileReader(csvFileName));

            //** Now using the OpenCSV **//
            CSVReader reader = new CSVReader(new FileReader("names.csv"), delimiter.charAt(0));
            //CSVReader reader = new CSVReader(csvReader);
            String[] nextLine;
            int line = 0;
            List<String> headers = new ArrayList<String>(5);
            while ((nextLine = reader.readNext()) != null) {

                if (line == 0) { // Header row
                    for (String col : nextLine) {
                        headers.add(col);
                    }
                } else { // Data row
                    Element rowElement = newDoc.createElement("row");
                    rootElement.appendChild(rowElement);

                    int col = 0;
                    for (String value : nextLine) {
                        String header = headers.get(col);

                        Element curElement = newDoc.createElement(header);
                        curElement.appendChild(newDoc.createTextNode(value.trim()));
                        rowElement.appendChild(curElement);

                        col++;
                    }
                }
                line++;
            }
            //** End of CSV parsing**//

            FileWriter writer = null;
            
            try {
            
                writer = new FileWriter(new File(xmlFileName));

                TransformerFactory tranFactory = TransformerFactory.newInstance();
                Transformer aTransformer = tranFactory.newTransformer();
                aTransformer.setOutputProperty(OutputKeys.INDENT, "yes");
                aTransformer.setOutputProperty(OutputKeys.METHOD, "xml");
                aTransformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");

                Source src = new DOMSource(newDoc);
                Result result = new StreamResult(writer);
                aTransformer.transform(src, result);
                
                writer.flush();

            } catch (Exception exp) {
                exp.printStackTrace();
            } finally {
                try {
                    writer.close();
                } catch (Exception e) {
                }
            }

            // Output to console for testing
            // Resultt result = new StreamResult(System.out);

        } catch (IOException exp) {
            System.err.println(exp.toString());
        } catch (Exception exp) {
            System.err.println(exp.toString());
        }
        return rowsCount;
        // "XLM Document has been created" + rowsCount;
    }
}

Next update (2022)

  • Added support for OpenCSV 5.*
  • Replace white spaces in header (at least as many as I can think of that will fit into a regular expression)

So, for example, using something like...

Reports Device Name IP Address  Interface Name  Interface   Description Time    Traffic Utilization Out Traffic bps 
Device1 1.1.1.1 5-Apr   Mon May 09 23:00:00 UTC 2022    0   0   0
Device2 1.1.1.1 5-Apr   Mon May 09 23:00:00 UTC 2022    0   0   0

It will generate an output of something like...

<XMLCreators>
    <row>
        <Reports>1</Reports>
        <Device_Name>2</Device_Name>
        <IP_Address>3</IP_Address>
        <Interface_Name>4</Interface_Name>
        <Interface>5</Interface>
        <Description>6</Description>
        <Time>7</Time>
        <Traffic>8</Traffic>
        <Utilization>9</Utilization>
        <Out_Traffic>10</Out_Traffic>
        <bps_>11</bps_>
    </row>
    <row>
        <Reports>Device1</Reports>
        <Device_Name>1.1.1.1</Device_Name>
        <IP_Address>5-Apr</IP_Address>
        <Interface_Name>Mon May 09 23:00:00 UTC 2022</Interface_Name>
        <Interface>0</Interface>
        <Description>0</Description>
        <Time>0</Time>
    </row>
    <row>
        <Reports>Device2</Reports>
        <Device_Name>1.1.1.1</Device_Name>
        <IP_Address>5-Apr</IP_Address>
        <Interface_Name>Mon May 09 23:00:00 UTC 2022</Interface_Name>
        <Interface>0</Interface>
        <Description>0</Description>
        <Time>0</Time>
    </row>
</XMLCreators>

Runnable example

import com.opencsv.CSVParser;
import com.opencsv.CSVParserBuilder;
import com.opencsv.CSVReader;
import com.opencsv.CSVReaderBuilder;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Main {
    public static void main(String[] args) {
        new Main();
    }

    public Main() {
        new XMLCreators().convertFile("Test.csv", "Test.xml", '\t');
    }

    public class XMLCreators {
        // Protected Properties

        protected DocumentBuilderFactory domFactory = null;
        protected DocumentBuilder domBuilder = null;

        public XMLCreators() {
            try {
                domFactory = DocumentBuilderFactory.newInstance();
                domBuilder = domFactory.newDocumentBuilder();
            } catch (FactoryConfigurationError exp) {
                System.err.println(exp.toString());
            } catch (ParserConfigurationException exp) {
                System.err.println(exp.toString());
            } catch (Exception exp) {
                System.err.println(exp.toString());
            }
        }

        public int convertFile(String csvFileName, String xmlFileName, char delimiter) {

            int rowsCount = -1;
            BufferedReader csvReader;
            try {
                Document newDoc = domBuilder.newDocument();
                // Root element
                Element rootElement = newDoc.createElement("XMLCreators");
                newDoc.appendChild(rootElement);
                // Read csv file
                csvReader = new BufferedReader(new FileReader(csvFileName));

                //** Now using the OpenCSV **//
                CSVParser parser = new CSVParserBuilder()
                        .withSeparator(delimiter)
                        .build();

                CSVReader reader = new CSVReaderBuilder(new FileReader(csvFileName))
                        .withCSVParser(parser)
                        .build();
                //CSVReader reader = new CSVReader(csvReader);
                String[] nextLine;
                int line = 0;
                List<String> headers = new ArrayList<String>(5);
                while ((nextLine = reader.readNext()) != null) {
                    if (line == 0) { // Header row
                        for (String col : nextLine) {
                            headers.add(col);
                        }
                    } else { // Data row
                        Element rowElement = newDoc.createElement("row");
                        rootElement.appendChild(rowElement);

                        int col = 0;
                        for (String value : nextLine) {
                            String header = headers.get(col).replaceAll("[\\t\\p{Zs}\\u0020]", "_");

                            Element curElement = newDoc.createElement(header);
                            curElement.appendChild(newDoc.createTextNode(value.trim()));
                            rowElement.appendChild(curElement);

                            col++;
                        }
                    }
                    line++;
                }
                //** End of CSV parsing**//

                FileWriter writer = null;

                try {

                    writer = new FileWriter(new File(xmlFileName));

                    TransformerFactory tranFactory = TransformerFactory.newInstance();
                    Transformer aTransformer = tranFactory.newTransformer();
                    aTransformer.setOutputProperty(OutputKeys.INDENT, "yes");
                    aTransformer.setOutputProperty(OutputKeys.METHOD, "xml");
                    aTransformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");

                    Source src = new DOMSource(newDoc);
                    Result result = new StreamResult(writer);
                    aTransformer.transform(src, result);

                    writer.flush();

                } catch (Exception exp) {
                    exp.printStackTrace();
                } finally {
                    try {
                        writer.close();
                    } catch (Exception e) {
                    }
                }

                // Output to console for testing
                // Resultt result = new StreamResult(System.out);
            } catch (IOException exp) {
                exp.printStackTrace();
            } catch (Exception exp) {
                exp.printStackTrace();
            }
            return rowsCount;
            // "XLM Document has been created" + rowsCount;
        }
    }
}
2 of 3
0
public int convertFile(String csvFileName, String xmlFileName, String delimiter) {

    int rowsCount = -1;
    try {
        Document newDoc = domBuilder.newDocument();
        // Root element
        Element rootElement = newDoc.createElement("XMLCreators");
        newDoc.appendChild(rootElement);
        // Read csv file
        BufferedReader csvReader;
        csvReader = new BufferedReader(new FileReader(csvFileName));
        int fieldCount = 0;
        String[] csvFields = null;
        String[] csvValues = null;


        // Assumes the first line in CSV file is column/field names
        // The column names are used to name the elements in the XML file,
        // avoid the use of Space or other characters not suitable for XML element
        // naming

        String curLine = csvReader.readLine();
        if (curLine != null) {
            csvFields=curLine.split(",", -1);
            }

        // At this point the coulmns are known, now read data by lines

        int i =0;
        while ((curLine = csvReader.readLine()) != null) {
            csvValues=curLine.split(",", -1);
            Element rowElement = newDoc.createElement("record-"+i);
            try {
            for(fieldCount=0;fieldCount<csvValues.length;fieldCount++)
            {
                String curValue = csvValues[fieldCount];
                Element curElement = newDoc.createElement(csvFields[fieldCount]);
                curElement.appendChild(newDoc.createTextNode(curValue));
                rowElement.appendChild(curElement);
            }
            } catch (Exception exp) {
            }
            rootElement.appendChild(rowElement);
            i++;

        }
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 128099 โ€บ languages โ€บ Converting-CSV-XML
Converting CSV to XML (XML forum at Coderanch)
I have tried http://servingxml.sourceforge.net/ and it seemed to meet my needs completely. It covers large range of conversions, requires only short learning curve (at least for basic transformations) and the author, Daniel Parker, provides excellent support. While testing this library I noticed a bug which Daniel has fixed the very next weekend. ... Hi, Anton Melumad can you please help me in undersanding the setting in getting the xml file out of the CSV file.