cancel
Showing results for 
Search instead for 
Did you mean: 

.xml to .csv file convertion

Former Member
0 Kudos

Dear all,

Can you please send me the java code for converting the .xml file to .csv file.

My xml structure is as follows

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml"/>

<ns0:EmployeeAssesmentSFACTOR xmlns:ns0="http://ehro.eds.com/FRAMEWORK/FileToFile">

<ASSESMENT>

<EMPLOYEENO>1</EMPLOYEENO>

<VALID_FROM>12</VALID_FROM>

<VALID_TO>13</VALID_TO>

<EMPLOYEERATING>

<DESCRIPTION>Sri ni</DESCRIPTION>

<RATING>A</RATING>

<COMMENT>good</COMMENT>

</EMPLOYEERATING>

</ASSESMENT>

</ns0:EmployeeAssesmentSFACTOR>

Your replies would be appreciated and rewarded with points

Thanks,

Srinivasa

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Srinivas,

If anyone give you program, it will complex for you to understand. So, What you can do is, read the node value using the code like this,

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

DocumentBuilder db = dbf.newDocumentBuilder();

NodeList nodes = doc.getElementsByTagName("ns0:EmployeeAssesmentSFACTOR");

for (int s = 0; s < nodes.getLength(); s++) {

Node CurNode = cur_Nodes.item(s);

String temp = CurNode.getNodeValue();

System.out.println(temp);

}

I have given some basics, you can develop your own based on this.

Regards,

Venkatesh. K

/* Points are Welcome */

former_member182294
Active Contributor
0 Kudos

Hi Srinivas,

Here is the example for <a href="http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/sax/work/Echo01.java">XML Parsing</a>.

Only thing you need to do is, as per your requirement you can convert this to write to a buffer as CSV files.

Regards

Abhilash