Read and Write xml Files
Read and Write xml Files
Rate Read and Write xml Files
(1(1 Vote))
' Copyright ©2001 Mike G --> IvbNET.COM
' All Rights Reserved, http://www.ivbnet.com
' EMAIL : [email protected]
' ------------------------------------------------------------
' You are free to use this code within your own applications,
' but you are forbidden from selling or distributing this
' source code without prior written consent.
' ------------------------------------------------------------
Private Sub cmdWite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdWite.Click
Call Write_XML()
End Sub
Private Sub Write_XML()
Dim XMLobj As Xml.XmlTextWriter
Dim enc As New System.[Text].UnicodeEncoding()
XMLobj = New Xml.XmlTextWriter("C:\test.xml", enc)
XMLobj.Formatting = Xml.Formatting.Indented
XMLobj.Indentation = 3
XMLobj.WriteStartDocument()
XMLobj.WriteStartElement("Books")
XMLobj.WriteStartElement("Book")
XMLobj.WriteAttributeString("ISBN", "100000000")
XMLobj.WriteAttributeString("Title", "IvbNET.com")
XMLobj.WriteAttributeString("Price", "50.00")
XMLobj.WriteEndElement()
XMLobj.WriteEndElement()
XMLobj.Close()
MsgBox("Done", MsgBoxStyle.Exclamation, "XML")
End Sub
Private Sub cmdRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRead.Click
Call Read_XML()
End Sub
Private Sub Read_XML()
Dim XMLReader As Xml.XmlReader
XMLReader = New Xml.XmlTextReader("C:\test.xml")
While XMLReader.Read
Select Case XMLReader.NodeType
Case Xml.XmlNodeType.Element
Debug.WriteLine(XMLReader.Name)
If XMLReader.AttributeCount > 0 Then
While XMLReader.MoveToNextAttribute
Debug.WriteLine(XMLReader.Name & "->" & XMLReader.Value)
End While
End If
Case Xml.XmlNodeType.Text
Debug.WriteLine(XMLReader.Value)
Case Xml.XmlNodeType.Comment
Debug.WriteLine(XMLReader.Value)
End Select
End While
XMLReader.Close()
MsgBox("Done", MsgBoxStyle.Exclamation, "XML")
End Sub
End Class
Read and Write xml Files Comments
No comments yet — be the first to post one!
Post a Comment