TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Demir Acar
NA
98
25.5k
export datagridview to xml
May 18 2014 12:04 PM
hi dear ;
At firstly I am fill to datagrid manually and save as Xml ,folowing this code,But if I fill to multiple rows in datagrid and then only export last rows
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
XmlTextWriter xmlDocument = new XmlTextWriter(@"d:\Deneme.xml", System.Text.Encoding.GetEncoding("ISO-8859-9"));
xmlDocument.Formatting = Formatting.Indented;
xmlDocument.Indentation = 5;
try
{
xmlDocument.WriteStartDocument();
xmlDocument.WriteStartElement("SALES_INVOICES");
xmlDocument.WriteElementString("TYPE", dataGridView1.Rows[i].Cells[0].Value.ToString());
xmlDocument.WriteEndElement();
xmlDocument.Close();
MessageBox.Show("Xml Created.");
}
catch (Exception ex)
{
MessageBox.Show("Hata" + ex.Message);
}
}
And Result is
<?xml version="1.0" encoding="iso-8859-9"?>
<SALES_INVOICES>
<TYPE>1453</TYPE>
</SALES_INVOICES>
I want to result is ;
<?xml version="1.0" encoding="iso-8859-9"?>
<SALES_INVOICES>
<TYPE>1452</TYPE>
</SALES_INVOICES>
<TYPE>1453</TYPE>
</SALES_INVOICES>
Thanks in advance
Reply
Answers (
3
)
XML
search files = problems