Reading/Writing user data to an XML file server-side

Germcloud

Member
Joined
Jun 6, 2010
Messages
9
Programming Experience
1-3
I am new to silverlight and have spent 4-5 days trying to find an answer. But here is what I'm trying to do.

As a simple project to help me learn, I wrote a small AdLib silverlight appliction. Basically, you're asked 10 questions and the program constructs a short story from your answers.

Now I'm trying to expand it. What I want to do now is allow the player to create their own story template and save it online to the webserver so others can choose from a list of user created stories to play with. They will be presented with a list of titles from other users that they can choose.

The application will display a simple form in which they enter their name, story title and story template. I then what my program to add their information to an existing xml file to be saved.

XML file I think might look like this:

<userdata>
<user id="000">
<name>Jeremy</jeremy>
<title>The Detective</title>
<story>short story template here</story>
</user>
<user id="001">
<name>James</jeremy>
<title>A Walk in the Park</title>
<story>short story template here</story>
</user>
</userdata>

Once they save their story, the program will add a user id "002" and the three elements with their information, name, title, story to the file.

So, I started researching, I thought starting off using a simple xml file instead of some database would be simple. But I kept running into road blocks, either code that I found was in C# and I didn't know enough to understand it, or it was using something called WCF or LINQ to SQL and databases, which I didn't want to use.

When I thought I found the answer, using XmlReader and XmlWriter, it turns out it's only using Isolated Storage on the user's computer, which I didn't want. I thought to embed the xml file as a resource inside the application, got the reading part down, but couldn't seem to write to it.

The more I research, the more different options I find for possible solutions. JSON, LINQ, WCF, ADO.NET.... and really at this point it feels like I'm really lost here because I don't know what any of this things are. I really thought it would be as easy as opening the file directly, extracting the data and closing it. From the information I'm finding, it seems that WCF allows you to read and write xml data to and from the server, but I'm having a hard time finding any VB samples on how this works.

If someone could point me in the right direction, where should I start?

What is the simplest, easiest why to do this?
I had wanted to start with XML because I think I know more of how it's structure works than anything else. I'm not worried about performance or file size or anything like that right now. If needed later, I will look into other things, unless it really is 100 times easier to use databases or something else, I just don't know anything about setting one up.

And if there are any samples out there, I will look at the C# but prefer VB, I know just very minimal C# and have a hard time translating it.

With that said, here is what I'm using.

Visual Web Developer Express 2010
Visual Basic Express 2010
I just got rid of my Linux Hosting and got Windows IIS I think, thought it work better this way, though I think it only lets me have one SQL database

Thank you in advance for taking the time to help me out.
 
I thought to embed the xml file as a resource inside the application, got the reading part down, but couldn't seem to write to it.
That would be your problem right there. Resources are embedded in the binary code of your executable. They are read-only. If you want to write data then you will have to use the file system. Any examples you can find that use an XmlWriter to write to a file will be relevant because, once you've created the writer, the code to use it is exactly the same no matter what's backing it.
 
Thanks for your reply. So, basically I can use the same code using XmlReader and XmlWriter to write to an xml file to the server once I've created a writer? What exactly is a writer and how do I use to make one?
 
Back
Top