Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have large XML file(194 mb). I want to convert it into a CSV file using C# code. Please help me.

Thanks in advance.

have done like this but empty file is generated.help me..
C#
static void Main(string[] args)
{
    getsubnode();
}

public static void getsubnode()
{
    XmlDocument doc = new XmlDocument();
    doc.Load("D:\\FXOPT\\EXP0D.xml");

    StreamWriter wr = new StreamWriter("D:\\X.csv", true);
    string Temp = "";
    wr.WriteLine(Temp);
    wr.Close();
            
}


[edit]added OP's update[/edit]

Please correct me if I am wrong.I dont want tags to be used in my code because file size is very big.Is there any solution for this?
Posted
Updated 30-Dec-10 18:14pm
v6

Start with the XmlReader[^] class to read your data and write the CSV data via a normal StreamWriter[^].
 
Share this answer
 
Comments
yaprig 29-Dec-10 7:06am    
have done like this but empty file is generated.help me..
static void Main(string[] args)
{
getsubnode();
}

public static void getsubnode()
{
XmlDocument doc = new XmlDocument();
doc.Load("D:\\FXOPT\\EXP0D.xml");



StreamWriter wr = new StreamWriter("D:\\X.csv", true);
string Temp = "";
wr.WriteLine(Temp);
wr.Close();

}
Well, you need to add all the code to extract the data from your XML document and write it to your output file. The code above writes a single blank line, so is not very useful. I suggest you spend some time studying the XMLDocument class and its methods to see how to extract the data. You will probably find some sample code on the internet if you try a Google search.
 
Share this answer
 
 
Share this answer
 
Comments
yaprig 30-Dec-10 0:15am    
I dont want tags to be used in my code because file size is very big.
Kasson 30-Dec-10 0:22am    
Good Call.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900