Write Birth Day in Existing in XML

Santosh4u
Posted by Santosh4u under VB.NET category on | Views : 1683
1. Add a Windows Form.
2. Drag one TextBox For Entering Name(txtName)
3. Drag one DateTimePicker For Selecting Date of Birth.(dtpBirthDate)
4. Drag a Button(btnWriteXML)
5. Dim XMLPath As String ="F:\XML Files\BirthDay.xml"
6 . Under btnWriteXML Click write below Code.
If txtName.Text = "" Then
MessageBox.Show("Please Enter Name", "BIRTH DAY", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Dim xmldoc As New Xml.XmlDocument
xmldoc.Load(XMLPath)
Dim node As XmlNode
node = xmldoc.CreateNode(XmlNodeType.Element, "BirthDay", "")
Dim Title As XmlNode = xmldoc.CreateElement("Name")
Dim Title1 As XmlNode = xmldoc.CreateElement("BirthDate", "")
Title.InnerText = txtName.Text
Title1.InnerText = dtpBirthDate.Text
node.AppendChild(Title)
node.AppendChild(Title1)
xmldoc.DocumentElement.AppendChild(node)
xmldoc.Save(XMLPath)
End If

Regards
Santosh

Comments or Responses

Login to post response