Follow by Email

Export xml data into text file

If you want to export attributes from XML file to text file then you just have to read that attribute from xml & write it in text file...I have shown hoe to write string into text file Here ....

Here is full code....Here i have used other way to write string into text file ie. WriteAllText function...

private void button1_Click(object sender, EventArgs e)

string text = select();

File.WriteAllText("file.txt", text);

public string select()
XmlDocument doc = new XmlDocument();
string s = "";
XmlNodeList nodes = doc.SelectNodes("/root/row");
foreach (XmlNode node in nodes)
XmlAttributeCollection att = node.Attributes;
foreach (XmlAttribute att1 in att)
s = s + att1.InnerText + System.Environment.NewLine;

return s;


Post a Comment