How to I acquire read-write codes for XML in VB.NET?
So I want to read-write XML functions in VB.NET.
Like this:
[
^]
But I want to adding for each using command.
(So: XML.Text = XML.Text + [Text])
What I have tried:
I want to like this codes for XML:
Public Class ini
Private Declare Ansi Function GetPrivateProfileString _
Lib "kernel32.dll" Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String,
ByVal lpKeyName As String, ByVal lpDefault As String,
ByVal lpReturnedString As System.Text.StringBuilder,
ByVal nSize As Integer, ByVal lpFileName As String) _
As Integer
Private Declare Ansi Function WritePrivateProfileString _
Lib "kernel32.dll" Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationName As String,
ByVal lpKeyName As String, ByVal lpString As String,
ByVal lpFileName As String) As Integer
Private Declare Ansi Function GetPrivateProfileInt _
Lib "kernel32.dll" Alias "GetPrivateProfileIntA" _
(ByVal lpApplicationName As String,
ByVal lpKeyName As String, ByVal nDefault As Integer,
ByVal lpFileName As String) As Integer
Private Declare Ansi Function FlushPrivateProfileString _
Lib "kernel32.dll" Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationName As Integer,
ByVal lpKeyName As Integer, ByVal lpString As Integer,
ByVal lpFileName As String) As Integer
Dim strFilename As String
Public Sub New(ByVal Filename As String)
strFilename = Filename
End Sub
ReadOnly Property FileName() As String
Get
Return strFilename
End Get
End Property
Public Function GetString(ByVal Section As String, ByVal Key As String, ByVal [Default] As String) As String
Dim intCharCount As Integer
Dim objResult As New System.Text.StringBuilder(256)
intCharCount = GetPrivateProfileString(Section, Key, [Default], objResult, objResult.Capacity, strFilename)
If intCharCount > 0 Then GetString = Left(objResult.ToString, intCharCount)
End Function
Public Function GetInteger(ByVal Section As String, ByVal Key As String, ByVal [Default] As Integer) As Integer
Return GetPrivateProfileInt(Section, Key, [Default], strFilename)
End Function
Public Function GetBoolean(ByVal Section As String, ByVal Key As String, ByVal [Default] As Boolean) As Boolean
Return (GetPrivateProfileInt(Section, Key, CInt([Default]), strFilename) = 1)
End Function
Public Sub WriteString(ByVal Section As String, ByVal Key As String, ByVal Value As String)
WritePrivateProfileString(Section, Key, Value, strFilename)
Flush()
End Sub
Public Sub WriteInteger(ByVal Section As String, ByVal Key As String, ByVal Value As Integer)
WriteString(Section, Key, CStr(Value))
Flush()
End Sub
Public Sub WriteBoolean(ByVal Section As String, ByVal Key As String, ByVal Value As Boolean)
WriteString(Section, Key, CStr(CInt(Value)))
Flush()
End Sub
Private Sub Flush()
FlushPrivateProfileString(0, 0, 0, strFilename)
End Sub
End Class