Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Read and Write XML files using VB.NET. ...
Author:
Mike G
E-mail:
Click to e-mail author
Website:
http://www.ivbnet.com
Submitted:
8/23/2001
Version:
VB.NET 2002
Compatibility:
VB.NET
Category:
XML
Views:
22125
Read and Write XML files using VB.NET.
Declarations:
'none
Code:
' ------------------------------------------------------------ ' Copyright ©2001 Mike G --> IvbNET.COM ' All Rights Reserved, http://www.ivbnet.com ' EMAIL : webmaster@ivbnet.com ' ------------------------------------------------------------ ' 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
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2023 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement