Simple XML in
Simple XML in
NET
This presentation will introduction
XML and using XML in .NET by
simplest way
(C# and VB.NET)
Introduction
XML is Extensible Markup Language. It is include
tag defined by user and text inside the tag. The
tag begin with < and end with >, tag have three
type:
start-tags; for example:<section>
end-tags; for example:</section>
empty-element tags; for example:<line-break/>
Introduction
Because the tag can be defined by user
so it can be used as database, or setting
of program, etc,...
And this presentation will intro simplest
way to read/write on XML document.
Attribute name
(color red)
Attribute value
(In double quote)
Inner text
Value
Anotherway
Imports System.Xml
Sub readValuexml ()
Dim xmltext As XmlTextReader = New XmlTextReader("example.xml")
Do While xmltext.Read
If xmltext.Name = "firstname" Then
ListBox1.Items.Add(xmltext.ReadElementString)
End If
Loop
End Sub
Sub writeXML()
Dim conn As New SqlConnection("Data
Source=localhost;Database=NorthWind;Integrated Security=True")
Search
This code will read data from XML file to DataSet, and using
Find() function of DataSet to find data.
Sub findInXML()
Dim ds As New DataSet
ds.ReadXml("example.xml")
Dim resultRow = ds.Tables(0).Select("firstname = 'Dale'")
If resultRow.Count = 0 Then
MsgBox("Could not be found")
Else
MsgBox("Found")
End If
End Sub
Reference
1.
2.
3.
4.
http://vb.net-informations.com/
www.codeproject.com
www.tutorialspoint.com
www.msdn.microsoft.com
About
Because this is the first presentation should not avoid errors. I
wellcome any contribute to this presentation more complete.
Any question or contribute please send for me via email
address: vohungvi@vohungvi.com or facebook:
fb.com/vohungvi