Solved

Save details to xml file?

Posted on 2009-06-29
6
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

695 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