473,382 Members | 1,107 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,382 software developers and data experts.

How to omit XmlTypeAttributes from List<T> class Properties? xsi:t


All,

I am at wits end with this one. Spent hours going through MSDN and online
articles to try to resolve this.

XmlSerializer is including the “xsi:type” attribute when I serialize a
property that is a List<Tof derived objects.

How do I stop this from happening?
Constraints:
XmlIncludeAttributes are unfeasible as bases classes are in separate
assemblies and know nothing of the specializations.
The context is not a web service. Just trying to get a text stream of the
serialized object using the XmlSerializer.

Thanks for all of your help.

[XmlRootAttribute(“Lot”, Namespace=”http://tempuri.org”)]
public class Car
{
}

[XmlRootAttribute(“Lot”, Namespace=”http://tempuri.org”)]
public class HotRod: Car
{
}
[XmlRootAttribute(“Lot”, Namespace=”http://tempuri.org”)]
public class Wagon: Car
{
}

[XmlRootAttribute(“Lot”, Namespace=”http://tempuri.org”)]
public class ParkingLot: Lot
{

[XmlArrayAttribute(“Cars”, Namespace=”http://tempuri.org”)]
[XmlArrayItemAttribute(“Car”, Namespace=”http://tempuri.org”)]
public List<CarCars {get; set}

}

ParkingLot should serialize like this:
<Lot xmlns=”http://tempuri.org”>
<Cars>
<Car></Car>
<Car></Car>
</Cars>
</Lot>
/************************************************** ******/
Reality Check
Instead, I get this:
This is a bit frustrating . . . . I have tried using
XmlAttributeOverrides, XmlTypeAttributes, etc etc.
Anyone know how to do this?
/************************************************** ******/

ParkingLot serializes like this instead:
<Lot xmlns=http://tempuri.org xmlns:xsi=”theXmlSchema-instance namespace”>
<Cars>
<Car xsi:Type=”HotRod”></Car>
<Car xsi:Type=”Wagon”></Car>
</Cars>
</Lot>

Jul 10 '06 #1
0 1126

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

Similar topics

4
by: matty.hall | last post by:
I have two classes: a base class (BaseClass) and a class deriving from it (DerivedClass). I have a List<DerivedClass> that for various reasons needs to be of that type, and not a List<BaseClass>....
5
by: PJ | last post by:
I have a class definition : public class PagingList<T> : List<T> { private int pageSize, pageNumber; public PagingList() { pageSize = (this.Count == 0) ? 1 : this.Count;...
6
by: Jeff.Boeker | last post by:
I'm learning a lesson in how I need to be more specific :) In C++ I can resize a vector and it will allocate memory and it will call the default constructor if necessary (or I can supply an...
9
by: Paul | last post by:
Hi, I feel I'm going around circles on this one and would appreciate some other points of view. From a design / encapsulation point of view, what's the best practise for returning a private...
0
by: submicron | last post by:
Hi All, I'm having problems implementing a readonly interface to a set of classes. Heres a simplification of the code: interface IreadonlyBase { // Does gets only on base class } class...
7
by: Andrew Robinson | last post by:
I have a method that needs to return either a Dictionary<k,vor a List<v> depending on input parameters and options to the method. 1. Is there any way to convert from a dictionary to a list...
44
by: Zytan | last post by:
The docs for List say "The List class is the generic equivalent of the ArrayList class." Since List<is strongly typed, and ArrayList has no type (is that called weakly typed?), I would assume...
45
by: Zytan | last post by:
This returns the following error: "Cannot modify the return value of 'System.Collections.Generic.List<MyStruct>.this' because it is not a variable" and I have no idea why! Do lists return copies...
35
by: Lee Crabtree | last post by:
This seems inconsistent and more than a little bizarre. Array.Clear sets all elements of the array to their default values (0, null, whatever), whereas List<>.Clear removes all items from the...
6
by: Peter | last post by:
I have a WebService which returns a List of RunningReport class How do I read this XML data on the client side. How do I convert List<RunningReportfrom the WebService side to List<RunningReporton...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.