I'm working on my high-school matriculation asp.net project, and I wish to make a website of a bookstore.
I want to create two classes,Book and BookStore, and save the data created in XML files and not in a database.
How can I save objects as XML files, and how can I load them afterwards?
Thank you very much.
You need to use XML serialisation. There are tons of examples of how to do this, but here's one link for you to get started:
http://devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=236
Related
I am facing a problem while working with xml file in asp.net mvc 5. I need to load a xml file. and read the xml data in different views. which have individual controller too. I have loaded the xml file successfully. But I can not catch the idea how can I pass the xml file data to other controller.
Like I have a Controller for loading the xml file. And I have another controller to read the xml data. Can you guys give me the idea how to do the rest work?
Sorry for my late answer. The problem was that I did not get full directory path to read the file. Then I created a cache memory to save the file and read it. And to read data in several controller I used like, Session["abc"] = "asas";
And to get this information in other controller, Viewbag.abc = Session["abc"];
I am working on a WPF project with C#.
There is a MainWindow and some other windows showing some data. I have also three XML files, where data from lists can be saved. The code is all written and works perfect.
Now my question is, how to save the whole file. I want to have the capability to, for example, save all the data into files, and user can open these files later and load the data into lists, and commence working, where they left the application before.
Can anybody help me?
If I understand your question correctly, you need to do it with following steps:
Save your XML files with a specific extension name.
you can achieve this by many ways: e.g. you can save your actual XML files into a location, and then just create a link file that contents links to these files. Or you can ZIP all the XML files into one single file.
link the default extension name to your application (so it will be opened by your application by default)
Open/read the file with XML content from your application.
Check this
Deserialize XML into items and display them in your list.
Trying to learn how to use OOXML to replace tokens win a word document by following this tutorial
Everything has been going pretty well until I hit this
Next, create the custom XML file containing the data for this document, and store it in the package.
Store the custom XML in memory and add placeholders for the actual data.
I'm having trouble discerning where to store the custom XML and what he means by storing it in memory.
The author also continues to refer to the file as package, so does that mean I should keep the word Template in .zip format?
Next, create the custom XML file containing the data for this document, and store it in the package.
In context, I would suggest the package is the file containing the xml data, which when you load it or display it becomes a document.
Storing it in memory, means loading an object with the data(i.e. xmldocument)
I have a rather complex XML file which I created a class for using the xsd tool. Now I added this created class to my project and want to access the actual XML data which is in the file. What do I do next?
Thanks :)
Next learn about xml serialization/deserialization. Here is tutorial ;)
I need a way to store data inside xml files and write to differant parts of the file, as well as add elements and structure to the xml document.
I need full control over the file names and xml documents, and it would be much easier if I could use some kind of SQL layer to read and write from the xml.
Just due to project constraints I am tied into using XML, but if possible would like a trust and tested open source solution for this.
Or should I be using out of box .net functionality for this?
you should be using out of box .net functionality.
the XML namespaces and Linq-to-XML will do this for you.