473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Serializing a class

Hi

I have written a class which is serializable. This works fine and the class
looks like this:
<Serializable()> Public Class Settings

Public Standard_DBVerknuepfung As String

Public Standard_NetDirNotfallPfad As String

Public Spezial_DBVerknuepfung As String

Public Spezial_NetDirNotfallPfad As String

End Class

When I serialize the class into a XML, then the XML-File looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Einstellungen xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Standard_DBVerknuepfung>W:\SBDATEN\ProgForm\SBSta rt.sbp</Standard_DBVerknuepfung>
<Standard_NetDirNotfallPfad>W:\SBDATEN</Standard_NetDirNotfallPfad>
<Spezial_DBVerknuepfung>C:\Restore\SBDATEN\PROGFOR M\SBStart.sbp</Spezial_DBVerknuepfung>
<Spezial_NetDirNotfallPfad>C:\Restore\SBDATEN</Spezial_NetDirNotfallPfad>
</Einstellungen>
Now I modified the XML-File and added second values for "Einstellungen":

<?xml version="1.0" encoding="utf-8"?>
<Einstellungen xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Standard_DBVerknuepfung>W:\SBDATEN\ProgForm\SBSta rt.sbp</Standard_DBVerknuepfung>
<Standard_NetDirNotfallPfad>W:\SBDATEN</Standard_NetDirNotfallPfad>
<Spezial_DBVerknuepfung>C:\Restore\SBDATEN\PROGFOR M\SBStart.sbp</Spezial_DBVerknuepfung>
<Spezial_NetDirNotfallPfad>C:\Restore\SBDATEN</Spezial_NetDirNotfallPfad>
</Einstellungen>
<Einstellungen>
<Standard_DBVerknuepfung>sdfasdf</Standard_DBVerknuepfung>
<Standard_NetDirNotfallPfad>sdfsdf</Standard_NetDirNotfallPfad>
<Spezial_DBVerknuepfung>sdfsdfsd</Spezial_DBVerknuepfung>
<Spezial_NetDirNotfallPfad>sdfsdfsd</Spezial_NetDirNotfallPfad>
</Einstellungen>

Now my question: What should I do deserialize all "Einstellungen" to my
class? I know that a array is needed, but how to do? If I let the
deserialize work trought, then I always get the values of the second
"Einstellungen"

Thanks for every help

Nijazi Halimaji
Nov 21 '05 #1
1 923
Hi Nijazi

What I generally do when I want to deserialise an xml file to an object
hierarchy in memory is do the reverse first. That is, I create the class
structure that I want in my programme, instantiate it, and then serialise it
to an xml file. That way, I create a file with exactly the right structure
for deserialisation.

If you create your array structure and serialise it, you will see exactly
how the file should be formed, and you are guaranteed to be able to
deserialise it.

HTH

Charles
"Nijazi Halimaji" <sp***@gmx.net> wrote in message
news:uP****************@TK2MSFTNGP14.phx.gbl...
Hi

I have written a class which is serializable. This works fine and the
class looks like this:
<Serializable()> Public Class Settings

Public Standard_DBVerknuepfung As String

Public Standard_NetDirNotfallPfad As String

Public Spezial_DBVerknuepfung As String

Public Spezial_NetDirNotfallPfad As String

End Class

When I serialize the class into a XML, then the XML-File looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Einstellungen xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<Standard_DBVerknuepfung>W:\SBDATEN\ProgForm\SBSta rt.sbp</Standard_DBVerknuepfung>
<Standard_NetDirNotfallPfad>W:\SBDATEN</Standard_NetDirNotfallPfad>

<Spezial_DBVerknuepfung>C:\Restore\SBDATEN\PROGFOR M\SBStart.sbp</Spezial_DBVerknuepfung>
<Spezial_NetDirNotfallPfad>C:\Restore\SBDATEN</Spezial_NetDirNotfallPfad>
</Einstellungen>
Now I modified the XML-File and added second values for "Einstellungen":

<?xml version="1.0" encoding="utf-8"?>
<Einstellungen xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<Standard_DBVerknuepfung>W:\SBDATEN\ProgForm\SBSta rt.sbp</Standard_DBVerknuepfung>
<Standard_NetDirNotfallPfad>W:\SBDATEN</Standard_NetDirNotfallPfad>

<Spezial_DBVerknuepfung>C:\Restore\SBDATEN\PROGFOR M\SBStart.sbp</Spezial_DBVerknuepfung>
<Spezial_NetDirNotfallPfad>C:\Restore\SBDATEN</Spezial_NetDirNotfallPfad>
</Einstellungen>
<Einstellungen>
<Standard_DBVerknuepfung>sdfasdf</Standard_DBVerknuepfung>
<Standard_NetDirNotfallPfad>sdfsdf</Standard_NetDirNotfallPfad>
<Spezial_DBVerknuepfung>sdfsdfsd</Spezial_DBVerknuepfung>
<Spezial_NetDirNotfallPfad>sdfsdfsd</Spezial_NetDirNotfallPfad>
</Einstellungen>

Now my question: What should I do deserialize all "Einstellungen" to my
class? I know that a array is needed, but how to do? If I let the
deserialize work trought, then I always get the values of the second
"Einstellungen"

Thanks for every help

Nijazi Halimaji

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Aleksei Guzev | last post by:
Imagine one writing a class library CL1 for data storage. He defines classes ‘DataItem’ and ‘DataRecord’ so that the latter contains a collection of the former. And he derives class ‘IntItem’ from...
0
by: Ante Smolcic | last post by:
Hi all, I have an ArrayList that contains items of type A. I declared the XmlArrayItem atribute for that type. Now I have an derived type B (from A) also contained in the ArrayList but I get...
4
by: Wayne Wengert | last post by:
I am still stuck trying to create a Class to use for exporting and importing array data to/from XML. The format of the XML that I want to import/export is shown below as is the Class and the code I...
1
by: Ivo Bronsveld | last post by:
All, I have quite a challenging task ahead of me. I need to write an object model (for code access) based on a schema, which cannot be made into a dataset because of it's complexity. So I...
2
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: +...
1
by: Derrick | last post by:
Hello all; I seem to be having some trouble serializing a class to XML. This code is a cut & paste from a project which used it perfectly, but all of a sudden I'm getting an error that the "dll...
4
by: Jason Shohet | last post by:
We are thinking of serializing an object & passing it toseveral functions on web service. This will happen about 35 times as the page loads. The class has about 20 attributes. We're not sure...
8
by: Joe | last post by:
Hello All: Say I have a solution with two projects (Project1 and Project2) and each project contains a class (Project1 contains Class1 and Project2 contains Class2). The projects don't...
3
by: Tom | last post by:
I am having trouble serializing a color property. Basically, it is not serializing the value. For instance, in the following: <Serializable()> _ Public Class TestColor Private _MyColor As...
7
by: fjlaga | last post by:
I have written an Office Add-in for Excel using VB.NET and the .NET 1.1 Framework (I have Visual Studio 2003 .NET ). All works great. I want to add a User Settings/Prefereneces dialog and allow...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.