473,804 Members | 3,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML Serialization of Arrays issues

I am using XML Serialization to output the IBuySpy tabs data.

I have used System.Xml.Seri alization to serialize an array of a class called
TabStripDetails . Using attributes I rename the resultant element in the XML
as MenuItem.:
[XmlType(TypeNam e="MenuItem")]

One of the members of the TabStripDetails class is of Collection type called
Tabs, and it may contain more instances of TabStripDetails (MenuItem). Using
Recursion, I successfully manage to Serialize the entire collection. Using
Attributes, I have denoted this collection member with the XMLElememt name
of "MenuGroup" .

However, I have two issues:
1) If the Tabs Collection is empty, I still get an empty XML element like
this:<MenuGroup/>,
placed within the <MenuItem>... </MenuItem> element.
Is there a way to not get <MenuGroup/> output if the collection in empty.
Would this with logic or with an Attribute?

2) The root element of the resulting XML is
<ArrayOfMenuIte m>...</ArrayOfMenuItem >.
The Root element should be is <MenuData>... </MenuData>

However, if I add to the above class attribute so that it is:

[XmlType(TypeNam e="MenuItem") , XmlRoot("MenuDa ta", Namespace = "",
IsNullable = false)]

the XML is still output with <ArrayOfMenuIte m> as Root Element

What do I need to do in order to get the preferred Root Element name of
<MenuData>?

Thanks
Nov 12 '05 #1
0 1552

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

Similar topics

16
9554
by: Bob Rock | last post by:
Hello, when serializing an array of elements of a class Classname using XmlSerializer.Serialize() I get an XML like the following: <?xml version="1.0"> <ArrayOfClassname> ....... ....... </ArrayOfClassname>
4
8712
by: hs | last post by:
Hi I am serializing a dataset using a binary formatter as follows: IFormatter formater = new BinaryFormatter(); formatter.Serialize(stream, ds); // ds=DataSet, stream=MemoryStream .... DataSet ds2 = (DataSet)formatter2.Deserialize(stream2); For the size of my DataSet, its taking 0.8 seconds to serialize and 2.3 seconds to deserialize.
3
3179
by: Aaron Clamage | last post by:
Hi, I'm not sure that if this is the right forum, but any help would be greatly appreciated. I am porting some java serialization code to c# and I can't figure out the correct way to do it. It seems that either I can use default serialization or implement ISerializable. Is there any way to do both (e.g. extend the default serialization). In other words, I want to be able to implement my custom serialization code but call the...
2
1581
by: Hasani | last post by:
If I have a base class that is derived from many classes, and I want to make all the classes serializable. Is there a way I can do this from the base class or must I add to every class, even if it's parent class has the attribute. I'm thinking no from what I've seen on google so far.
2
2543
by: Luck | last post by:
Hi, I really need some expert help... please! Basically, I need to serialize a data structure object to a file using SOAP and then load and de-serialize that file in ANOTHER program. When I serialize / deserialize the object in the SAME application, it works fine but when I simply copy the identical code to another application and try deserialization from that second application, I get the error: An unhandled exception of type...
4
6787
by: martin.skarsaune | last post by:
We have some SOAP compatilibility issues with Visual Studio .NET. Procedure: 1. Add web reference by importing WSDL from an external system 2. Generate C# classes 3. Try to invoke the remote service Problem 1: Wrapping in arrays If the WSDL file includes a repeating element: <xsd:element name="blabla" maxOccurs="unbounded">
4
2005
by: Michael Maes | last post by:
Hi, How would I make a class implementing a Singleton Pattern serializable. My problem is the Singleton Pattern 'requires' the constructor to be Private and serialization requires the constructor to be Public. Thanks, Michael
0
3038
by: ronnotel | last post by:
I have integrated APIs from a third party into my framework. The third party is essentially a .Net wrapper on top of an existing set of C++ classes and structs. I want to pass-around objects in these native structures as much as possible - that is I don't want to fool around with object serialization/deserialization. Data rates approach several hundred thousand objects per second, hence I simply can't pay the performance penalty this...
10
5125
by: aaragon | last post by:
Hello everyone, I've been trying to create a simple way to serialize C++ objects so I can send messages among different processors (using MPI). Something very simple is shown below: template <class StorageType> void Send(StorageType& c, int dest, int tag, MPI_Comm comm) { typedef typename StorageType::ValueType ValueType;
0
9591
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10594
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
10343
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
10331
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
10087
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
9166
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...
0
6861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4306
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
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.