برای نوشتن در فایل xml
Private Function SaveCredentials(ByVal Username As String, _
ByVal Password As String, _
ByVal PasswordConfirm As String) As Boolean
Dim LoginDS As DataSet = New DataSet

Try
LoginDS.ReadXml(Page.Server.MapPath("Users.xml"))
Catch fnf As System.IO.FileNotFoundException
CreateBlankUsersFile()
LoginDS.ReadXml(Page.Server.MapPath("Users.xml"))
End Try

If Not LoginDS.Tables(0).Select("username='" & _
Username & "'").Length > 0 Then
If _password <> "" And _
_password = _passwordConfirm Then
Dim NewLogin As DataRow = LoginDS.Tables(0).NewRow

NewLogin("username") = _userName
NewLogin("password") = _
FormsAuthentication. _
HashPasswordForStoringInConfigFile(_password, _
"MD5")
NewLogin("registerDate") = _
DateTime.Today.ToShortDateString
LoginDS.Tables(0).Rows.Add(NewLogin)
LoginDS.WriteXml(Page.Server.MapPath("Users.xml"))
_statusMessage = "کاربر مورد نظر به سیستم اضافه شد."
Return True
Else
_statusMessage = "رمز عبور درست وارد نشده است "
Return False
End If
Else
_statusMessage = "نام کاربر در سیستم وجود دارد . " & _
"لطفا نام دیگری انتخاب کنید."
Return False
End If
End Function
Public Sub CreateBlankUsersFile()
Dim NewXml As System.IO.StreamWriter = _
System.IO.File.CreateText(Page.Server.MapPath("Use rs.xml"))

NewXml.WriteLine("<users>")
'user field describes a single user
NewXml.WriteLine(" <user>")
'date field contains the Registration date
NewXml.WriteLine(" <registerDate>" & _
DateTime.Today.ToShortDateString & "</registerDate>")
'username field
NewXml.WriteLine(" <username>Admin</username>")
'password field contains MD5 hash value
NewXml.WriteLine(" <password>" & _
FormsAuthentication.HashPasswordForStoringInConfig File("password", _
"MD5") & "</password>")
NewXml.WriteLine(" </user>")
NewXml.WriteLine("</users>")
NewXml.Close()
End Sub

برای خوندنش
Private Function VerifyCredentials(ByVal Username As String, _
ByVal Password As String) As Boolean
Dim LoginDS As DataSet = New DataSet

LoginDS.ReadXml(Page.Server.MapPath("Users.xml"))

If LoginDS.Tables(0).Select("username='" & _
Username & " '").Length > 0 Then
Dim LoginRow() As DataRow = _
LoginDS.Tables(0).Select("username='" & _
Username & "'")
If LoginRow(0).Item("password").ToString = _
FormsAuthentication. _
HashPasswordForStoringInConfigFile(Password, _
"MD5") Then

Return True

Else
_statusMessage = "رمز عبور نادرست است ."
Return False
End If
Else
_statusMessage = "کاربر مورد نظر در سیستم یافت نشد."
Return False
End If
End Function