Dim domxmldocument As System.Xml.XmlDocument
Dim Tmppath As String = Apptempfilepath
Dim xmlfile As String = Tmppath + "\testxml.xml"
' Form Load Event
Private Sub Testxml_load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Read XML process test through
Dim domxmldocument As System.Xml.XmlDocument
Dim Tmppath As String = Apptempfilepath
Dim xmlfile As String = Tmppath + "\testxml.xml"
Dim reader As System.Xml.XmlReader = Nothing
Try
reader = new Xml.xmltextreader (xmlfile)
' Reader.
While Reader.read
Me.lboxxml.items.add (Reader.name + reader.value)
End While
Catch ex As exception
MsgBox (Ex.message)
Finally
If not (reader are nothing) then
Reader.close ()
End If
End Try
End Sub
' Load XML events
Private Sub Btnxmlload_click (ByVal sender As System.Object, ByVal e As System.EventArgs) handles Btnxmlload.click
' Me.lboxxml.items.clear ()
"Read the XML process test through
' Dim reader As System.Xml.XmlReader = Nothing
' Try
' Reader = new Xml.xmltextreader (xmlfile)
' While Reader.read
' Me.lboxxml.items.add (Reader.name + ":" + reader.value)
' End While
' Catch ex As Exception
' MsgBox (Ex.message)
' Finally
' If not ' (reader are nothing) then
' Reader.close ()
' End If
' End Try
Dim ds As New DataSet
Try
' If you use DS to do DataSource, you will not expand the DataGrid, with DV you can directly display the correct.
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
Catch ex As exception
MsgBox (ex.message.tostring)
End Try
End Sub
' Save new XML content Event
Private Sub Btnsavenew_click (ByVal sender As System.Object, ByVal e As System.EventArgs) handles Btnsavenew.click
Dim mytw As New XmlTextWriter (Tmppath + "\testxmlwrite.xml", Nothing)
Mytw.writestartdocument ()
mytw.formatting = formatting.indented
Mytw.writestartelement ("Team")
Mytw.writestartelement ("Player")
Mytw.writeattributestring ("name", "George Zip")
Mytw.writeattributestring ("position", "QB")
Mytw.writeelementstring ("nickname", "Zippy")
Mytw.writeelementstring ("Jerseynumber", xmlconvert.tostring (7))
Mytw.writeendelement ()
Mytw.writeendelement ()
Mytw.writeenddocument ()
Mytw.close ()
End Sub
In large files, consider manually implementing a data update adapter, such as manually implementing an XML node search/update, so that you do not have to rewrite the entire XML.
If the program's I/O is not a major problem, or the entire write update with the entity class, after all, the integrity of the data is the first.
If the article class, the directory to build an XML index file to store the number of articles, URLs, and so on, using XML attributes as tags in different fields, content pages can be stored in another HTML or XML pages, using LINQ to XML data, the efficiency is not very poor, personal point of view. When searching, it's OK to just query for the filename XML or file type.