Solved

Save details to xml file?

Posted on 2009-06-29
6
279 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

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

829 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