how to read/write properties to xml file for later retrieval?

I want to save my class property data into an xml file for later use i

  • (2 Pages)
  • +
  • 1
  • 2

21 Replies - 8971 Views - Last Post: 09 September 2009 - 11:07 PM Rate Topic: -----

#1 adam p  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-August 09

how to read/write properties to xml file for later retrieval?

Post icon  Posted 31 August 2009 - 12:39 PM

First off I am fairly new to VB .net however I have had some success in my project so far. I am creating a simple envelope accounting program for personal use. So far I have some basic forms created and have my class defined and a few methods for calculating my balances as well as changing the property data I want to work with. I now want to take this property data and save it to an xml file that I can easily retrieve the data into another form and save for later.

Here is a screen shot of the form used to gather the property data for my class
Attached Image

Here's the class code:
Public Class EnvelopeSystem
#Region "Identification"
	Private eUsername As String = ""
	Public Property Username() As String
		Get
			Return eUsername
		End Get
		Set(ByVal value As String)
			eUsername = value
		End Set
	End Property
#End Region

#Region "Pay Types"
	'-------------------------------------------------------
	'Pay Period Types as Boolean(true/false) values
	'-------------------------------------------------------

	Private ePPMonthly As Boolean = False
	Public Property PPMonthly() As Boolean
		Get
			Return ePPMonthly
		End Get
		Set(ByVal value As Boolean)
			ePPMonthly = value
		End Set
	End Property

	Private ePPBiWeekly As Boolean = True
	Public Property PPBiWeekly() As Boolean
		Get
			Return ePPBiWeekly
		End Get
		Set(ByVal value As Boolean)
			ePPBiWeekly = value
		End Set
	End Property

	Private ePPWeekly As Boolean = False
	Public Property PPWeekly() As Boolean
		Get
			Return ePPWeekly
		End Get
		Set(ByVal value As Boolean)
			ePPWeekly = value
		End Set
	End Property

	Private ePPLump As Boolean = False
	Public Property PPLump() As Boolean
		Get
			Return ePPLump
		End Get
		Set(ByVal value As Boolean)
			ePPLump = value
		End Set
	End Property
#End Region

#Region "Pay Amounts"

	'-------------------------------------------------------
	'Pay Amounts for each Pay Type used on the Pay sheets
	'-------------------------------------------------------

	Private ePayMonthly As Double = 0
	Public Property PayMonthly() As Double
		Get
			Return ePayMonthly
		End Get
		Set(ByVal value As Double)
			ePayMonthly = value
		End Set
	End Property

	Private ePayBi1 As Double = 0
	Public Property PayBi1() As Double
		Get
			Return ePayBi1
		End Get
		Set(ByVal value As Double)
			ePayBi1 = value
		End Set
	End Property

	Private ePayBi2 As Double = 0
	Public Property PayBi2() As Double
		Get
			Return ePayBi2
		End Get
		Set(ByVal value As Double)
			ePayBi2 = value
		End Set
	End Property

	Private ePayWeek1 As Double = 0
	Public Property PayWeek1() As Double
		Get
			Return ePayWeek1
		End Get
		Set(ByVal value As Double)
			ePayWeek1 = value
		End Set
	End Property

	Private ePayWeek2 As Double = 0
	Public Property PayWeek2() As Double
		Get
			Return ePayWeek2
		End Get
		Set(ByVal value As Double)
			ePayWeek2 = value
		End Set
	End Property

	Private ePayWeek3 As Double = 0
	Public Property PayWeek3() As Double
		Get
			Return ePayWeek3
		End Get
		Set(ByVal value As Double)
			ePayWeek3 = value
		End Set
	End Property

	Private ePayWeek4 As Double = 0
	Public Property PayWeek4() As Double
		Get
			Return ePayWeek4
		End Get
		Set(ByVal value As Double)
			ePayWeek4 = value
		End Set
	End Property

	Private ePayLump As Double = 0
	Public Property PayLump() As Double
		Get
			Return ePayLump
		End Get
		Set(ByVal value As Double)
			ePayLump = value
		End Set
	End Property
#End Region

#Region "Balances"
	'-------------------------------------------------------
	'Balances for Pay Types to be used on Pay sheets
	'-------------------------------------------------------

	Private eMonthlyBal As Double = 0
	Public Property MonthlyBal() As Double
		Get
			Return eMonthlyBal
		End Get
		Set(ByVal value As Double)
			eMonthlyBal = value
		End Set
	End Property

	Private eBiWeeklyBal1 As Double = 0
	Public Property BiWeeklyBal1() As Double
		Get
			Return eBiWeeklyBal1
		End Get
		Set(ByVal value As Double)
			eBiWeeklyBal1 = value
		End Set
	End Property

	Private eBiWeeklyBal2 As Double = 0
	Public Property BiWeeklyBal2() As Double
		Get
			Return eBiWeeklyBal2
		End Get
		Set(ByVal value As Double)
			eBiWeeklyBal2 = value
		End Set
	End Property

	Private eWeeklyBal1 As Double = 0
	Public Property WeeklyBal1() As Double
		Get
			Return eWeeklyBal1
		End Get
		Set(ByVal value As Double)
			eWeeklyBal1 = value
		End Set
	End Property

	Private eWeeklyBal2 As Double = 0
	Public Property WeeklyBal2() As Double
		Get
			Return eWeeklyBal2
		End Get
		Set(ByVal value As Double)
			eWeeklyBal2 = value
		End Set
	End Property

	Private eWeeklyBal3 As Double = 0
	Public Property WeeklyBal3() As Double
		Get
			Return eWeeklyBal3
		End Get
		Set(ByVal value As Double)
			eWeeklyBal3 = value
		End Set
	End Property

	Private eWeeklyBal4 As Double = 0
	Public Property WeeklyBal4() As Double
		Get
			Return eWeeklyBal4
		End Get
		Set(ByVal value As Double)
			eWeeklyBal4 = value
		End Set
	End Property

	Private eLumpBal As Double = 0
	Public Property LumpBal() As Double
		Get
			Return eLumpBal
		End Get
		Set(ByVal value As Double)
			eLumpBal = value
		End Set
	End Property
#End Region

#Region "Envelopes"
	'-------------------------------------------------------
	'Envelope Account Names & Associated Values and Balances
	'-------------------------------------------------------

	Private eEnvName1 As String = "Account 1 Name"
	Public Property EnvName1() As String
		Get
			Return eEnvName1
		End Get
		Set(ByVal value As String)
			eEnvName1 = value
		End Set
	End Property

	Private eEnvAmount1 As Double = 0
	Public Property EnvAmount1() As Double
		Get
			Return eEnvAmount1
		End Get
		Set(ByVal value As Double)
			eEnvAmount1 = value
		End Set
	End Property

	Private eEnvBalance1 As Double = 0
	Public Property EnvBalance1() As Double
		Get
			Return eEnvBalance1
		End Get
		Set(ByVal value As Double)
			eEnvBalance1 = value
		End Set
	End Property

	Private eEnvName2 As String = "Account 2 Name"
	Public Property EnvName2() As String
		Get
			Return eEnvName2
		End Get
		Set(ByVal value As String)
			eEnvName2 = value
		End Set
	End Property

	Private eEnvAmount2 As Double = 0
	Public Property EnvAmount2() As Double
		Get
			Return eEnvAmount2
		End Get
		Set(ByVal value As Double)
			eEnvAmount2 = value
		End Set
	End Property

	Private eEnvBalance2 As Double = 0
	Public Property EnvBalance2() As Double
		Get
			Return eEnvBalance2
		End Get
		Set(ByVal value As Double)
			eEnvBalance2 = value
		End Set
	End Property

	Private eEnvName3 As String = "Account 3 Name"
	Public Property EnvName3() As String
		Get
			Return eEnvName3
		End Get
		Set(ByVal value As String)
			eEnvName3 = value
		End Set
	End Property

	Private eEnvAmount3 As Double = 0
	Public Property EnvAmount3() As Double
		Get
			Return eEnvAmount3
		End Get
		Set(ByVal value As Double)
			eEnvAmount3 = value
		End Set
	End Property

	Private eEnvBalance3 As Double = 0
	Public Property EnvBalance3() As Double
		Get
			Return eEnvBalance3
		End Get
		Set(ByVal value As Double)
			eEnvBalance3 = value
		End Set
	End Property

	Private eEnvName4 As String = "Account 4 Name"
	Public Property EnvName4() As String
		Get
			Return eEnvName4
		End Get
		Set(ByVal value As String)
			eEnvName4 = value
		End Set
	End Property

	Private eEnvAmount4 As Double = 0
	Public Property EnvAmount4() As Double
		Get
			Return eEnvAmount4
		End Get
		Set(ByVal value As Double)
			eEnvAmount4 = value
		End Set
	End Property

	Private eEnvBalance4 As Double = 0
	Public Property EnvBalance4() As Double
		Get
			Return eEnvBalance4
		End Get
		Set(ByVal value As Double)
			eEnvBalance4 = value
		End Set
	End Property

	Private eEnvName5 As String = "Account 5 Name"
	Public Property EnvName5() As String
		Get
			Return eEnvName5
		End Get
		Set(ByVal value As String)
			eEnvName5 = value
		End Set
	End Property

	Private eEnvAmount5 As Double = 0
	Public Property EnvAmount5() As Double
		Get
			Return eEnvAmount5
		End Get
		Set(ByVal value As Double)
			eEnvAmount5 = value
		End Set
	End Property

	Private eEnvBalance5 As Double = 0
	Public Property EnvBalance5() As Double
		Get
			Return eEnvBalance5
		End Get
		Set(ByVal value As Double)
			eEnvBalance5 = value
		End Set
	End Property

	Private eEnvName6 As String = "Account 6 Name"
	Public Property EnvName6() As String
		Get
			Return eEnvName6
		End Get
		Set(ByVal value As String)
			eEnvName6 = value
		End Set
	End Property

	Private eEnvAmount6 As Double = 0
	Public Property EnvAmount6() As Double
		Get
			Return eEnvAmount6
		End Get
		Set(ByVal value As Double)
			eEnvAmount6 = value
		End Set
	End Property

	Private eEnvBalance6 As Double = 0
	Public Property EnvBalance6() As Double
		Get
			Return eEnvBalance6
		End Get
		Set(ByVal value As Double)
			eEnvBalance6 = value
		End Set
	End Property

	Private eEnvName7 As String = "Account 7 Name"
	Public Property EnvName7() As String
		Get
			Return eEnvName7
		End Get
		Set(ByVal value As String)
			eEnvName7 = value
		End Set
	End Property

	Private eEnvAmount7 As Double = 0
	Public Property EnvAmount7() As Double
		Get
			Return eEnvAmount7
		End Get
		Set(ByVal value As Double)
			eEnvAmount7 = value
		End Set
	End Property

	Private eEnvBalance7 As Double = 0
	Public Property EnvBalance7() As Double
		Get
			Return eEnvBalance7
		End Get
		Set(ByVal value As Double)
			eEnvBalance7 = value
		End Set
	End Property

	Private eEnvName8 As String = "Account 8 Name"
	Public Property EnvName8() As String
		Get
			Return eEnvName8
		End Get
		Set(ByVal value As String)
			eEnvName8 = value
		End Set
	End Property

	Private eEnvAmount8 As Double = 0
	Public Property EnvAmount8() As Double
		Get
			Return eEnvAmount8
		End Get
		Set(ByVal value As Double)
			eEnvAmount8 = value
		End Set
	End Property

	Private eEnvBalance8 As Double = 0
	Public Property EnvBalance8() As Double
		Get
			Return eEnvBalance8
		End Get
		Set(ByVal value As Double)
			eEnvBalance8 = value
		End Set
	End Property

	Private eEnvName9 As String = "Account 9 Name"
	Public Property EnvName9() As String
		Get
			Return eEnvName9
		End Get
		Set(ByVal value As String)
			eEnvName9 = value
		End Set
	End Property

	Private eEnvAmount9 As Double = 0
	Public Property EnvAmount9() As Double
		Get
			Return eEnvAmount9
		End Get
		Set(ByVal value As Double)
			eEnvAmount9 = value
		End Set
	End Property

	Private eEnvBalance9 As Double = 0
	Public Property EnvBalance9() As Double
		Get
			Return eEnvBalance9
		End Get
		Set(ByVal value As Double)
			eEnvBalance9 = value
		End Set
	End Property

	Private eEnvName10 As String = "Account 10 Name"
	Public Property EnvName10() As String
		Get
			Return eEnvName10
		End Get
		Set(ByVal value As String)
			eEnvName10 = value
		End Set
	End Property

	Private eEnvAmount10 As Double = 0
	Public Property EnvAmount10() As Double
		Get
			Return eEnvAmount10
		End Get
		Set(ByVal value As Double)
			eEnvAmount10 = value
		End Set
	End Property

	Private eEnvBalance10 As Double = 0
	Public Property EnvBalance10() As Double
		Get
			Return eEnvBalance10
		End Get
		Set(ByVal value As Double)
			eEnvBalance10 = value
		End Set
	End Property
#End Region

#Region "Class Constructor"
	Public Sub New()

	End Sub
#End Region

#Region "Methods"

	Public Sub CalcMonthyBal()
		eMonthlyBal = ePayMonthly - eEnvAmount1 - eEnvAmount2 - eEnvAmount3 - eEnvAmount4 - eEnvAmount5 - eEnvAmount6 - eEnvAmount7 - eEnvAmount8 - eEnvAmount9 - eEnvAmount10
	End Sub

	Public Sub CalcBiWeeklyBal1()
		eBiWeeklyBal1 = ePayBi1 - eEnvAmount1 - eEnvAmount2 - eEnvAmount3 - eEnvAmount4 - eEnvAmount5 - eEnvAmount6 - eEnvAmount7 - eEnvAmount8 - eEnvAmount9 - eEnvAmount10
	End Sub

	Public Sub CalcBiWeeklyBal2()
		eBiWeeklyBal2 = ePayBi2 - eEnvAmount1 - eEnvAmount2 - eEnvAmount3 - eEnvAmount4 - eEnvAmount5 - eEnvAmount6 - eEnvAmount7 - eEnvAmount8 - eEnvAmount9 - eEnvAmount10
	End Sub

	Public Sub CalcWeeklyBal1()
		eWeeklyBal1 = ePayWeek1 - eEnvAmount1 - eEnvAmount2 - eEnvAmount3 - eEnvAmount4 - eEnvAmount5 - eEnvAmount6 - eEnvAmount7 - eEnvAmount8 - eEnvAmount9 - eEnvAmount10
	End Sub

	Public Sub CalcWeeklyBal2()
		eWeeklyBal2 = ePayWeek2 - eEnvAmount1 - eEnvAmount2 - eEnvAmount3 - eEnvAmount4 - eEnvAmount5 - eEnvAmount6 - eEnvAmount7 - eEnvAmount8 - eEnvAmount9 - eEnvAmount10
	End Sub

	Public Sub CalcWeeklyBal3()
		eWeeklyBal3 = ePayWeek3 - eEnvAmount1 - eEnvAmount2 - eEnvAmount3 - eEnvAmount4 - eEnvAmount5 - eEnvAmount6 - eEnvAmount7 - eEnvAmount8 - eEnvAmount9 - eEnvAmount10
	End Sub

	Public Sub CalcWeeklyBal4()
		eWeeklyBal4 = ePayWeek4 - eEnvAmount1 - eEnvAmount2 - eEnvAmount3 - eEnvAmount4 - eEnvAmount5 - eEnvAmount6 - eEnvAmount7 - eEnvAmount8 - eEnvAmount9 - eEnvAmount10
	End Sub

	Public Sub CalcLumpBal()
		eLumpBal = ePayLump - eEnvAmount1 - eEnvAmount2 - eEnvAmount3 - eEnvAmount4 - eEnvAmount5 - eEnvAmount6 - eEnvAmount7 - eEnvAmount8 - eEnvAmount9 - eEnvAmount10
	End Sub

#End Region

End Class


Here is the code for the form:
Imports System.Windows.Forms

Public Class SetupMonthly

	Private MonthlyBudget As New EnvelopeSystem

	Private Sub PropogateMonthlyProperties()
		MonthlyBudget.PayMonthly = Txt_MPayAmt.Text
		MonthlyBudget.EnvName1 = Txt_MName1.Text
		MonthlyBudget.EnvName2 = Txt_MName2.Text
		MonthlyBudget.EnvName3 = Txt_MName3.Text
		MonthlyBudget.EnvName4 = Txt_MName4.Text
		MonthlyBudget.EnvName5 = Txt_MName5.Text
		MonthlyBudget.EnvName6 = Txt_MName6.Text
		MonthlyBudget.EnvName7 = Txt_MName7.Text
		MonthlyBudget.EnvName8 = Txt_MName8.Text
		MonthlyBudget.EnvName9 = Txt_MName9.Text
		MonthlyBudget.EnvName10 = Txt_MName10.Text
		MonthlyBudget.EnvAmount1 = Txt_MAmt1.Text
		MonthlyBudget.EnvAmount2 = Txt_MAmt2.Text
		MonthlyBudget.EnvAmount3 = Txt_MAmt3.Text
		MonthlyBudget.EnvAmount4 = Txt_MAmt4.Text
		MonthlyBudget.EnvAmount5 = Txt_MAmt5.Text
		MonthlyBudget.EnvAmount6 = Txt_MAmt6.Text
		MonthlyBudget.EnvAmount7 = Txt_MAmt7.Text
		MonthlyBudget.EnvAmount8 = Txt_MAmt8.Text
		MonthlyBudget.EnvAmount9 = Txt_MAmt9.Text
		MonthlyBudget.EnvAmount10 = Txt_MAmt10.Text
		MonthlyBudget.CalcMonthyBal()
		RTxt_MBal.Text = MonthlyBudget.MonthlyBal
	End Sub


	Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_MonNext.Click
		Me.DialogResult = System.Windows.Forms.DialogResult.OK
		Me.Close()
	End Sub

	Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
		Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
		Me.Close()
		Start.Visible = True
	End Sub

	Private Sub SetupMonthly_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

	End Sub

	Private Sub Btn_MonBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_MonBack.Click
		Me.Visible = False
		Start.Visible = True
	End Sub

	Private Sub NextToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NextToolStripMenuItem.Click
		Me.DialogResult = System.Windows.Forms.DialogResult.OK
		Me.Close()
	End Sub

	Private Sub CancelToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CancelToolStripMenuItem.Click
		Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
		Me.Close()
		Start.Visible = True
	End Sub

	Private Sub BackToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackToolStripMenuItem.Click
		Me.Visible = False
		Start.Visible = True
	End Sub

	Private Sub Btn_CalMonBal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_CalMonBal.Click
		PropogateMonthlyProperties()

	End Sub

End Class



I am looking for advice on how to get this to xml the most efficient way possible. Any links or guidance on how to do this will be greatly appreciated.

Also if there are any blatant errors or easier ways to code what I already have I am still very new at this and would be glad to see easier more efficient ways of coding.

Thanks in advance for any advice.

Is This A Good Question/Topic? 0
  • +

Replies To: how to read/write properties to xml file for later retrieval?

#2 PDUNZ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 43
  • View blog
  • Posts: 372
  • Joined: 17-July 09

Re: how to read/write properties to xml file for later retrieval?

Posted 31 August 2009 - 05:38 PM

Cant say I have played with XML, but would this be of any help?

XML Programming using VB.NET
Was This Post Helpful? 1
  • +
  • -

#3 adam p  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-August 09

Re: how to read/write properties to xml file for later retrieval?

Posted 31 August 2009 - 06:45 PM

View PostPDUNZ, on 31 Aug, 2009 - 04:38 PM, said:

Cant say I have played with XML, but would this be of any help?

XML Programming using VB.NET


Yes this is definitely a step in the right direction. Thank You for the link! Now I need to find a good reference on the XML syntax...checking www.w3c.org
Was This Post Helpful? 0
  • +
  • -

#4 CakeMaker  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 69
  • Joined: 20-August 09

Re: how to read/write properties to xml file for later retrieval?

Posted 31 August 2009 - 07:50 PM

OMG!!! I just got done figuring this out myself so I think I can help. I am a noob too, so bare with me here...

All the user settings in my program are saving to an XML Configuration File with My.Settings. When I was in my class file, I could get and set them but then they would reset when the program was restarted...or I couldn't access them or something, I can't remember. But I did figure it out. I have used your example to input just 1 line of code...I hope this is a step towards what you're needing.

Public Class EnvelopeSystem
#Region "Identification"
	Private eUsername As String = ""
	Public Property Username() As String
		Get
			Return eUsername
		End Get
		Set(ByVal value As String)
			eUsername = value
				MyProgram.My.Settings.eUsername = value
		End Set
	End Property
#End Region



This will update your My.Settings that is saving to the XML configuration file. Then you can access it from your program to retreive the saved values that you are working with here.

This post has been edited by CakeMaker: 31 August 2009 - 07:52 PM

Was This Post Helpful? 0
  • +
  • -

#5 adam p  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-August 09

Re: how to read/write properties to xml file for later retrieval?

Posted 31 August 2009 - 08:18 PM

This would work, however what I am wanting to do is this:
  • Programmatically create a well formed xml file with corresponding elements relating to my class properties
  • Write the property data to the xml file in the associated elements
  • Read/Load the data from these elements into multiple forms to be further modified and stored
  • I NEED the ability for the user to at will create a new dataset based upon the class and xml setup and save this data in separate files for retrieval at another date and possibly for document reporting in the future.
I have explored the idea of using a database for this, however what I have found is that I really don't need the overhead of a database system when a set of xml files should do just fine.
Was This Post Helpful? 0
  • +
  • -

#6 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1046
  • View blog
  • Posts: 4,072
  • Joined: 02-July 08

Re: how to read/write properties to xml file for later retrieval?

Posted 31 August 2009 - 08:31 PM

Hey adam_p look into XML serialization/deserialization. You can create a well formed XML from a class, parse it later, or deserialize it later to rebuild your dataset or other objects for use in code. There many good examples on the internet. I have just started using them myself - great tool!
Was This Post Helpful? 0
  • +
  • -

#7 adam p  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-August 09

Re: how to read/write properties to xml file for later retrieval?

Posted 31 August 2009 - 08:50 PM

Thanks Hawkvalley1 I will do that.
Was This Post Helpful? 0
  • +
  • -

#8 CakeMaker  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 69
  • Joined: 20-August 09

Re: how to read/write properties to xml file for later retrieval?

Posted 31 August 2009 - 11:01 PM

Well poo...I thought I was helping :D.

But, isn't there a way to do what you're wanting by creating a new dataset based off the values from your saved My.Settings?

My program saves all the user's prices. They can change them and it saves them too in the XML file. I can pull those prices at any time, and create anything I want based off of thier values.

Now, since your wanting them saved in separate files, have you thought about just exporting the settings to a file...perhaps I'm such a noob I am misunderstanding :).
Was This Post Helpful? 0
  • +
  • -

#9 adam p  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-August 09

Re: how to read/write properties to xml file for later retrieval?

Posted 01 September 2009 - 05:00 AM

I could probably very easily use My.Settings to do this however as I said before I want the data to be compartmentalized into separate files. I am wanting to save My.Settings for application configuration settings that the user can customize.

Don't think that you aren't helping at all CakeMaker as I didn't really think about doing it that way. Now that I have thought about it I have decided that's not the route I want to go with my data. Your suggestion has been helpful and I do appreciate it.
Was This Post Helpful? 0
  • +
  • -

#10 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1046
  • View blog
  • Posts: 4,072
  • Joined: 02-July 08

Re: how to read/write properties to xml file for later retrieval?

Posted 01 September 2009 - 09:27 AM

If you don't already - get a XML editor - I am using Liguid XML Studios Comm. Edition, and it works great for my needs, and you can edit the XSD's. By the way serialization makes an XSD and not an XML so giving it the correct extension in the streamwriter/reader will save you some errors. :ph34r:
Was This Post Helpful? 0
  • +
  • -

#11 adam p  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-August 09

Re: how to read/write properties to xml file for later retrieval?

Posted 01 September 2009 - 09:02 PM

Thanks for the advice. Is Liquid XML Studios freeware or is that commercial? I will probably need to find something either open source or freeware.
Was This Post Helpful? 0
  • +
  • -

#12 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: how to read/write properties to xml file for later retrieval?

Posted 02 September 2009 - 04:29 AM

What you are trying to accomplish can be done with datasets

Datasets can read and write to xml.

The nice thing is you can databind datasets to your controls. (less code)

The properties for each field will be generated for you.

I just think in this case its a total re-think of your project but nevertheless, Working with databound and typed datasets is so much easier.
Was This Post Helpful? 0
  • +
  • -

#13 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: how to read/write properties to xml file for later retrieval?

Posted 02 September 2009 - 04:38 AM

add a datset to your project

add a datatable to your datset (not table adapter)

add coloumns to your datatable and provide the correct datatypes

open your for and select your datasources

drag the datatable you created onto the form

now you should be able to use the following to write data

DataSet1.DataTable1.WriteXml("YourFileName.xml")



and

DataSet1.DataTable1.ReadXml("YourFileName.xml") 



to read the data
Was This Post Helpful? 0
  • +
  • -

#14 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: how to read/write properties to xml file for later retrieval?

Posted 02 September 2009 - 04:52 AM

Here is an example application its in VB 2008

But it shows how easy it is to use xml in datsets.

If you doubleclick any field in the dataset you can do validation there etc.
Was This Post Helpful? 0
  • +
  • -

#15 adam p  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-August 09

Re: how to read/write properties to xml file for later retrieval?

Posted 02 September 2009 - 07:31 PM

Thanks Motcom I will give that a shot, after I look at that example. I hope it's as easy as that.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2