Solved

Save details to xml file?

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now