Gaurav Singh

Gaurav Singh

  • NA
  • 0
  • 25.3k

how do i get data from xml

Jan 20 2016 12:41 AM
I have created a form which have two text boxes. txtName and txtJob.
What i did is whenever user enter Name and job in respective boxes,
those Name and Job got saved as xml like this
<!--Name job Configuration-->
'<'NameJobConfig'>'
 ' <'Name>NameFromTextBox'<'/'Name'>
  <'job'>JobFromTextBox '<'/'job'>'
'<'/'NameJobConfig'>'
========================
My code :

XDocument xNameJobXml = new XDocument(

new XDeclaration("1.0", "utf-16", "yes"),

new XComment("Name job Configuration"),

new XElement("NameJobConfig",

new XElement("Name", txtName.Text),

new XElement("job", txtJob.Text))

);

msg = xNameJobXml.ToString();

}

==================

i saved this xml as string in a string variable msg. This xml persist somewhere in collection as string.
now i want when i run the instance again i want to retrieve the data "Name" and "Job" into txtName field and txtJob field
from that xml which i had generated and and saved in string var..

How can i do it? Looping through string which is holding the xml? plz help me.



Answers (2)