on 08-29-2007 12:51 PM
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
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 */
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.