Solved

Save details to xml file?

Posted on 2009-06-29
6
278 Views
Last Modified: 2012-05-07
Hi,

I have a form that allows a user to enter details about their location that I want to save to an xml file so they dont have to renter the details each time. This way I can set it to save multiple location details in future.

The problem I have is I dont know how to write the details to an xml file.

The form has textboxes for:

Location
Name
Telephone Number

I'm wanting to set a button to write these to an xml file so it would look like..

<site>
<location>New york</location>
<name>Paul</name>
<phone>00000000</phone>
</site>

Can anyone show me how I can go about this?

Thanks,
Paul.
0
Comment
Question by:m0tSiE
  • 2
  • 2
6 Comments
 
LVL 11

Expert Comment

by:bmatumbura
ID: 24736757
This sample project may help:

http://www.freevbcode.com/ShowCode.Asp?ID=6322

0
 

Author Comment

by:m0tSiE
ID: 24737774
I tried downlaoding the source files but it wasn't compatible with vb.net.
0
 
LVL 13

Accepted Solution

by:
game-master earned 500 total points
ID: 24741383


good morning!
try sumthing like this...

sub WriteXml()

Try
            Dim xmlSetting As New Xml.XmlWriterSettings
            xmlSetting.Indent = True

            Dim writer As Xml.XmlWriter = Xml.XmlWriter.Create("Sample.xml", xmlSetting)
            With writer
                .WriteStartDocument()
                .WriteStartElement("Site")
                .WriteElementString("Location", location.text)
                .WriteElementString("Name", name.text)
                .WriteElementString("Phone", phonenumber.text)
                .WriteEndElement()
                .WriteEndDocument()
                .Flush()
            End With
            MessageBox.Show("Done")
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try


end sub


i hope i can give u idea...

game-master
0
 

Author Closing Comment

by:m0tSiE
ID: 31597937
Cheers! :D
0
 
LVL 13

Expert Comment

by:game-master
ID: 24966686


thank you for accepting my answer....

i just got my guru level.... :-)



Praise Be Unto God!

game-master
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question