Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I M newbie for vs2008
i m start a new project
it has 6 textboxes
my problem is that
how to load textbox value from text file
like this
text file data is
<name>Alex</name>
<age>22</age>
<address>57, rd street</address>
<city>DC</city>
<state>califonia</state>
<pin>00000</pin>

I want to load in my application like this
Textbox1.text = "Alex"
Textbox2.text = "22"
Textbox3.text = "57, rd street"
Textbox4.text = "DC"
Textbox5.text = "california"
Textbox6.text = "00000"

Thanks in Advance
Posted

What sort of project is this, homework ? You should talk to your teacher and look at your reference material, in order to at least try to do this, before asking for help. Also assume your teacher can google and find your question. I assume there's no way you're being paid for this, that would be an utter disgrace.

The XmlDocument class will let you read an XML file, you can load it using File.ReadAllText. Then use XPath to select the nodes and read the values out of them using the DOM methods provided by .NET.
 
Share this answer
 
Your XML file is not having a valid root node. Unless you follow the document structure you wont be able to use XMLReader or XMLDocument or Serialization on the input file. You can use TextReader for reading the file, then parse the data as required and assign back to the textbox.

Is this any homework for you? For last one month you are asking the same kind of questions? Please do read some books before jumping into coding.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900