Note: I mainly refer to the online article name: "XML operation in VB and VB.NET" article URL: http://www.wrclub.net/study/listacticle.aspx? Id = 1459
Inside the general process, it is in my actual application process.
In the article code:
DIM mysdd as system.xml.xmldataDocumentmyxdd = new system.xml.xmldataDocument (me.dsmaster1) Myxdd.load ("dataonly.xml") setbindings (me.dsmaster1)
Setbindings has never known something, can't find in MSDN, so don't do it in accordance with his article method. Referring with MSDN, this article is more big for my help, although I also led to some detours.
Here main posts from two events, the way to load XML into the DataGrid:
'If you use DS directly to do DataSource, you will not expand the DataGrid, you can display it directly with DV. Dim ds As DataSet = New DataSet ds.ReadXml (xmlFile) Dim tb As DataTable Dim dv As DataView tb = ds.Tables (0) dv = New DataView (tb) 'DataGrid1.DataSource = dv' DataGrid1.DataMember = "testXmlMember" 'DataGrid1.Datamember = "Employeefname"' DIM DXD AS New XmldataDocument DataGrid1.SetDataBinding (DV, "") XMLDD = New XMLDATADOCUMENT (DS)
Note the position of the two reference variables of DS and XMLDD. Find MSDN to find the corresponding help. Specifically, avoid repeated binding errors.
Another event is in the preserved event, as long as it is called directly:
XMLDD.SAVE (XMLFile)
I.e.
This allows XML display in the GRID, then saved the content in the GRID to the XML file by saving.
Everything is difficult, open a head, it is not so difficult!
If you use .NET to operate XML, I think the class is the class is Xmldocument, XmlReader, XMLWriter. And their derivative class, can be found in MSDN!
The next task is to get a node, then only need to update a node, and the correct object is related to the correct object through the XML relationship table!