Possible Duplicate:
How to modify XML data in Dom parser
I am new working in Java and XMl DOm parser. I had a requirment like read the xml data and store it inform of column and rows type. this is a sample code
ki need to read this XMl file and store it in the above format:
Expected Output"
swetha,Eunis,swetha,10000
john,MAdiv,Jo,200000
But i am getting spaces between them, for 4 tags 4 spaces are coming Output of the below Code:
swetha,Eunis,swetha,10000
john,MAdiv,Jo,200000
Java Code:
NodeList nl= doc.getElementsByTagName("*");
for(int i=1;i< nl.getLength();i++)
{
Element section = (Element) nl.item(i);
Node title = section.getFirstChild();
while (title != null && title.getNodeType() != Node.ELEMENT_NODE)
{
title = title.getNextSibling();
if (title != null)
{
String first=title.getFirstChild().getNodeValue().trim();
if(first!=null)
{
title = title.getNextSibling();
System.out.print(first + ",");
br.write(first + ",");
}
}
}//WHILE
br.write("/n");
System.out.print("\n");
}
I am not able to find how to remove spces between the lines.