473,748 Members | 4,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Serialize 2 nodes

Hi,

I have a class that I am trying to serialize. To simplify, I've changed the
names to Baseball, Teams and Players. Here is what the XML should look like:

<BaseBall>
<Teams>
<Team>
<Name />
<City />
</Team>
</Teams>
<Players>
<Player>
<FirstName />
<LastName />
</Player>
</Players>
</BaseBall>

I have a Team class, Player class, TeamCollection class, PlayerCollectio n
class and a Baseball class. I can add Teams to the TeamCollection and
serialize it to XML with out any problems. I can add Players to the
PlayerCollectio n and serialize it to XML with out any problems. When I try
to add a TeamCollection or PlayerCollectio n to the Baseball class I get an
error that says: "You must implement a default accessor on
Baseball.DataAc cess+BaseballCo llection because it inherits from ICollection."
Can anyone provide a simple example of the correct way to do this?

Nov 12 '05 #1
3 2164
Take a look at [0] where you'll find a detailed answer and some code
examples.

HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko

-----Original Message-----
From: CLEAR-RCIC [mailto:CL****** *@discussions.m icrosoft.com]
Posted At: Monday, January 24, 2005 7:59 AM
Posted To: microsoft.publi c.dotnet.xml
Conversation: Serialize 2 nodes
Subject: Serialize 2 nodes

Hi,

I have a class that I am trying to serialize. To simplify, I've changed the
names to Baseball, Teams and Players. Here is what the XML should look like:

<BaseBall>
<Teams>
<Team>
<Name />
<City />
</Team>
</Teams>
<Players>
<Player>
<FirstName />
<LastName />
</Player>
</Players>
</BaseBall>

I have a Team class, Player class, TeamCollection class, PlayerCollectio n class and a Baseball class. I can add Teams to the TeamCollection and
serialize it to XML with out any problems. I can add Players to the
PlayerCollectio n and serialize it to XML with out any problems. When I try
to add a TeamCollection or PlayerCollectio n to the Baseball class I get an error that says: "You must implement a default accessor on
Baseball.DataAc cess+BaseballCo llection because it inherits from
ICollection."
Can anyone provide a simple example of the correct way to do this?

Nov 12 '05 #2
J L
I am also interested. What does [0] mean?

John

On Tue, 25 Jan 2005 21:21:47 -0600, "Christoph Schittko [MVP]"
<IN**********@a ustin.rr.com> wrote:
Take a look at [0] where you'll find a detailed answer and some code
examples.

HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko

-----Original Message-----
From: CLEAR-RCIC [mailto:CL****** *@discussions.m icrosoft.com]
Posted At: Monday, January 24, 2005 7:59 AM
Posted To: microsoft.publi c.dotnet.xml
Conversation: Serialize 2 nodes
Subject: Serialize 2 nodes

Hi,

I have a class that I am trying to serialize. To simplify, I've

changed
the
names to Baseball, Teams and Players. Here is what the XML should

look
like:

<BaseBall>
<Teams>
<Team>
<Name />
<City />
</Team>
</Teams>
<Players>
<Player>
<FirstName />
<LastName />
</Player>
</Players>
</BaseBall>

I have a Team class, Player class, TeamCollection class,

PlayerCollecti on
class and a Baseball class. I can add Teams to the TeamCollection and
serialize it to XML with out any problems. I can add Players to the
PlayerCollectio n and serialize it to XML with out any problems. When

I
try
to add a TeamCollection or PlayerCollectio n to the Baseball class I

get an
error that says: "You must implement a default accessor on
Baseball.DataAc cess+BaseballCo llection because it inherits from
ICollection."
Can anyone provide a simple example of the correct way to do this?


Nov 12 '05 #3
It means I forgot to paste the link I referenced ;)

Should be:

[0]
http://www.topxml.com/xmlserializer/...on_classes.asp
-----Original Message-----
From: J L [mailto:jo**@mar ymonte.com]
Posted At: Wednesday, January 26, 2005 5:16 PM
Posted To: microsoft.publi c.dotnet.xml
Conversation: Serialize 2 nodes
Subject: Re: Serialize 2 nodes

I am also interested. What does [0] mean?

John

On Tue, 25 Jan 2005 21:21:47 -0600, "Christoph Schittko [MVP]"
<IN**********@a ustin.rr.com> wrote:
Take a look at [0] where you'll find a detailed answer and some code
examples.

HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko

-----Original Message-----
From: CLEAR-RCIC [mailto:CL****** *@discussions.m icrosoft.com]
Posted At: Monday, January 24, 2005 7:59 AM
Posted To: microsoft.publi c.dotnet.xml
Conversation: Serialize 2 nodes
Subject: Serialize 2 nodes

Hi,

I have a class that I am trying to serialize. To simplify, I've

changed
the
names to Baseball, Teams and Players. Here is what the XML should

look
like:

<BaseBall>
<Teams>
<Team>
<Name />
<City />
</Team>
</Teams>
<Players>
<Player>
<FirstName />
<LastName />
</Player>
</Players>
</BaseBall>

I have a Team class, Player class, TeamCollection class,

PlayerCollecti on
class and a Baseball class. I can add Teams to the TeamCollection and serialize it to XML with out any problems. I can add Players to the PlayerCollectio n and serialize it to XML with out any problems.
WhenI
try
to add a TeamCollection or PlayerCollectio n to the Baseball class I

get an
error that says: "You must implement a default accessor on
Baseball.DataAc cess+BaseballCo llection because it inherits from
ICollection."
Can anyone provide a simple example of the correct way to do this?


Nov 12 '05 #4

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

Similar topics

2
6737
by: Jim Cobban | last post by:
I must be missing something. I am using org.apache.xml.serialize.XMLSerializer to save a DOM but I am not getting non-basic characters converted to UTF-8. I create Text nodes in the DOM by, for example: Document doc; JTextArea textPrompt; Text newTextNode;
3
4806
by: Jim Cobban | last post by:
I must be missing something. I am using org.apache.xml.serialize.XMLSerializer to save a DOM but I am not getting non-basic characters converted to UTF-8. I create Text nodes in the DOM by, for example: Document doc; JTextArea textPrompt; Text newTextNode;
0
1583
by: serge calderara | last post by:
Dear all, I am looking for a solution to serialize complete treeview nodes structure in a file or database or XML and deserialize it back when needed. this to save the current nodes information and restore them based on user profile. Thnaks for your information
14
14308
by: vince | last post by:
Can I add (append) to an xml file that already contains a serialized object, and be able to deserialize to either or both objects from the same file...??? How is this done...?? thanks, vince
0
3442
by: meh | last post by:
Still have not been able to convert this. More importently.....Is this sample going about it the right way??? tia meh Here is the vb code.........I keep looking at older vb.net projects to try and figure out how to teach myself C# based on my old vb code but it's been more difficult than I first thought. I'm finding that it would be better if didn't know any previous programming language.
3
7579
by: Toxick | last post by:
Hello experts, I'm a total C# noob with a total C# noob question. I've been Serializing in C++ (MFC) and writing data to std::fstreams for quite some time, so maybe I'm not understanding this different technique, or reading too much into it, or not enough: but, I'm not quite wrapping my brain around serialization in C#.
3
8050
by: Eric | last post by:
I need to send an object between nodes on a network. Each node currently communicates fine with sending strings around but I can't figure out how to deserialize objects using the same basic infrastructure. I'm currently using MS's basic server example for my code: public static void AcceptCallback(IAsyncResult ar) { // Signal the main thread to continue. allDone.Set();
17
1873
by: Peter | last post by:
How would would you deserialize this example below? Imports System Imports System.Collections Imports System.IO Imports System.Xml.Serialization Public Class App1 Shared Sub Main()
4
2263
by: teddysnips | last post by:
I would like to serialize a class to XML. The format of the XML is fixed (see below). It only needs to be serialized - it is read by another application. I know I can do it manually using XMLTextWriter - e.g. Dim xwriter = New XmlTextWriter("C:\Projects\Formflo\WindowsService\NDde\test.xml", System.Text.Encoding.UTF8) xwriter.Formatting = Formatting.Indented
0
9530
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9312
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8237
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.