Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi i have textboxe(s) and i wanna to insert the data that i fill the form with it in xml file..how i can do that..is there any code could help me ,since i try different codes and don't work with me
Posted
Comments
Sergey Alexandrovich Kryukov 17-Jun-12 15:23pm    
You don't explain where to insert and what should it mean, so it cannot be answered.
--SA

1 solution

The problem is: if you "try different codes" instead of doing programming, even if you get some help, it would be useless for you. You did not explain how you work with XML in general, where the data should be inserted, what's your goal. The question has nothing to do with ASP.NET, so you should remove this tag.

So, here is some ideas: 1) XML is structured, so you can insert some data in XML node, not XML; 2) you should work with XML, not XML file; so, you can read and parse the whole XML, modify it, and write the whole thing to the file; you can do it if the data is small enough to fit in memory; 3) better yet, you should work with data, not with XML; so learn about serialization and use it.

http://en.wikipedia.org/wiki/Serialization[^],
http://msdn.microsoft.com/en-us/library/ms233843.aspx[^],
http://msdn.microsoft.com/en-us/library/7ay27kt9%28v=vs.100%29.aspx[^],
http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

—SA
 
Share this answer
 
Comments
jkirkerx 17-Jun-12 18:06pm    
I have to agree, it's like wanting to cook dinner, first you need to settle on a dish, figure out the receipe, and then aquire the food you need to prepare and cook the dish.

So first you create your xml file, with the required elements and nodes. And then you write code to read the file. Then write code to write the first xml file, and then write code to update the file with a new record.

With xml, you really can't just copy and paste your way to success.
Sergey Alexandrovich Kryukov 29-Jun-12 22:40pm    
Good point. But you can create data model first, then create a sample instance of data in memory and then run serializer to store it. Now you have a sample XML conforming the schema. You can read it back, use as a template to manual editing, whatever. Makes sense, right?
--SA
jkirkerx 30-Jun-12 14:20pm    
I was just trying to simplify the thinking process for XML.

I personally create the model by writing out the XML file by hand, and then I create XSD code to match the file. Next I test the XSD, to make sure it creates the multiple element records correctly.

After that, I run the XSD against xsd.exe to create a class, and use the class to read, write and update. I use XMLTextWriter and XMLTextReader, and it works quite well.

I just looked at your name, and realized that your the Russian guy with a million points, who's way beyond my skill level.
Sergey Alexandrovich Kryukov 30-Jun-12 23:50pm    
Yes, I'm Russian, but absolutely not sure about comparison of skill levels. The most common situation is when skills cannot be compared. And no points really measure them... :-)
--SA
jkirkerx 1-Jul-12 1:22am    
Well, that was modest and well thought out, and I feel better about the level playing field which is not measured by points. Not so intimated now.

I've always been fascinated by Russian Programmers. I have a deep respect for them. I have lots of questions.

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