Hi at all!
I have a problem with writing form a datagridview into an XML file. Before that I read data from an XML a show the data in an DataGridView. This works correctly. If I add now some Data to the Datagridview and try to write the new data into the existing XML file. But unfortunately the Data is written into the wrong node.
I read the data form the XML to the datagridview like that:
I try to write data like that:
My XML file looks like that:
But if I add now a new row to the datagridview and try to save the new datagridview in the XML the XML file is saved like this:
So my problem is now that the data will be added to another node not to the node I want to have the data. Which other possibility I have to write into the XML file keeping the old node strucuture?
I have a problem with writing form a datagridview into an XML file. Before that I read data from an XML a show the data in an DataGridView. This works correctly. If I add now some Data to the Datagridview and try to write the new data into the existing XML file. But unfortunately the Data is written into the wrong node.
I read the data form the XML to the datagridview like that:
Code
DataSet As New DataSet
'reads the xml-File
DataSet.ReadXml(xmlPath)
'write the data in the datagridView
Me.DataGridView1.DataSource = DataSet
Me.DataGridView1.DataMember = "book"I try to write data like that:
Code
DataSet.WriteXml(newXmlPath)My XML file looks like that:
Code
<?xml version="1.0"?>
<catalog>
<book_list>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
</book_list>
</catalogBut if I add now a new row to the datagridview and try to save the new datagridview in the XML the XML file is saved like this:
Code
<?xml version="1.0"?>
<catalog>
<book_list>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
</book_list>
<book>
<author>Galos, Mike</author>
<title>Visual Studio 7: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>49.95</price>
<publish_date>2001-04-16</publish_date>
<description>Microsoft Visual Studio 7 is explored in depth,
looking at how Visual Basic, Visual C++, C#, and ASP+ are
integrated into a comprehensive development
environment.</description>
</book>
</catalog>So my problem is now that the data will be added to another node not to the node I want to have the data. Which other possibility I have to write into the XML file keeping the old node strucuture?

