Pages

Men

rh

7/18/2013

How to pass text box values to an XML?

//declare an XMLDoc and Attribute

dim Attr as Xml Attribute

dim doc as XmlDoc

doc.load("yourXMLpath")

'Create an Element
Dim elem As XmlElement = doc.CreateElement("Person")

'Create an Attribute
Attr = doc.Create Attribute("Fname")

'Assign the value of ur text box
Attr.Value = txtFirstName.Text

elem.Attributes.SetNamedItem(Attr)

Attr = doc.Create Attribute("Lname")

Attr.Value = txtLastName.Text

elem.Attributes.SetNamedItem(Attr)

Dim root As XmlNode = doc.DocumentElement

root.AppendChild(elem)

'Save the documnet

doc.Save("d:Gayathri.xml")

No comments :

Post a Comment