xml-serialization

[C#]Test if a class can be serialized

I want to create a generic method to serizlize a class to text (for use as part of a networking component) The method should be something like: public string SerializeToText<T>(T DataToSerialize); The method contents would simply perform the xml serialization and I can do this. What I want to know is if I can check whether T can be s...

Deserializing inherited types without explicit XmlArrayItem attribute

I have an XML document that looks like this: <MyEntity> <Vehicles> <Car /> <Truck /> </Vehicles> </MyEntity> I want to deserialise it into the following structure: public class MyEntity { public Vehicle[] Vehicles { get; set; } } public class Vehicle {} public class Car : Vehicle {} public class Truck : V...

What is the purpose of the PropertySpecified pattern used by XML Serialization ?

What is the purpose of the PropertySpecified pattern used by XML Serialization ? What problem does it tryto solve ? ...

Can you iterate over the XmlAttributeOverrides collection in c#

Hi All, I have to dynamically assign and change complex objects attributes at run time using the System.Xml.Serialization.XmlAttributeOverrides So far I have been able to do everything i needed. My one question is how can I iterate through the collection to see what has already been added? And if I can't interate through this collec...

SAX Parser and XML Schema (XSD) validation

Which Java XML libraries can do SAX-based parsing and validation against an XML Schema (XSD) at the same time? I'm really looking for the most efficient solution for reading and validating large XML files. bonus points if you can provide sample code. ...

WCF contracts - namespaces and SerializationExceptions

I am using a third party web service that offers the following calls and responses http://api.athirdparty.com/rest/foo?apikey=1234 <response> <foo>this is a foo</foo> </response> and http://api.athirdparty.com/rest/bar?apikey=1234 <response> <bar>this is a bar</bar> </response> This is the contract and supporting types I wrot...

xsd.exe to C# - any way to get an ArrayList instead of an Array?

This issue is somewhat related: http://stackoverflow.com/questions/1165999/problem-with-code-generated-by-xsd-exe-sequence-of-elements-is-generated-as-an-a Basically, I would rather work with an ArrayList in C# code then an array. I have a collection of errors, and I'm writing code to send back additional errors to the already existin...

Java Object to XML serialization using writeObject

Is there any open source Object to XML serializer in Java that uses writeObject method on the object to serialize similar to NSXMLOutputStream in WebObjects? ...

Xml serialization with deep indent.

Hi I'm not so good at this but I have a huge interest. :) How can I serialize this xml? <A> <B> <C>1600</C> </B> <B> <C> <F>34</F> </C> </B> <D> <E>1400</E> </D> </A> ...

xml serialization with foreign keys

I have a program that uses a lot of xml serialization for storage purposes, because at this point in time a database is inaccessible for the specific project. Is there any inherit way to lace 'Ids' in foreign collections similar to how they would work as foreign keys in a database? For example... <Client> <Name>Client A</Name> <Addr...

Serialize an object to string

I have the following method to save an Object to a file: // Save an object out to the disk public static void SerializeObject<T>(this T toSerialize, String filename) { XmlSerializer xmlSerializer = new XmlSerializer(toSerialize.GetType()); TextWriter textWriter = new StreamWriter(filename); xmlSerializer.Serialize(textWrite...

'Semi' Generic Dictionary Serialization. (C#)

Using a reference from... http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx I have a serializable generic dictionary. One thing I wanted to do is to add the Key into the Attribute nodes of the Values (just because It's how I wanted it formatted). Oftentimes, the Key is just a string. Is there any way to force the class to...

Serializing Class Derived from Generic Collection yet Deserializing the Generic Collection

I have a Repository Class with the following method... public T Single<T>(Predicate<T> expression) { using (var list = (Models.Collectable<T>)System.Xml.Serializer.Deserialize(typeof(Models.Collectable<T>), FileName)) { return list.Find(expression); } } Where Collectable is defined.. [Serializable] public class Co...

Using .NET XmlSerializer with get properties and setter functions

I'm trying to use XmlSerializer from C# to save out a class that has some values that are read by properties (the code being just a simple retrieval of field value) but set by setter functions (since there is a delegate called if the value changes). What I'm currently doing is this sort of thing. The intended use is to use the InT prop...

Custom XML Serialization, how to write custom root element?

I'm probably just doing this wrong, i know. I'm using custom serialization and when the xml is generated it's putting the class name as the root element Example: <MyClassName> <MyIntendedRootNode> <ObjectType> <Property1/> <Property2/> ... I'm invoking the serialization by calling xmlserializer.Serialize(writer,Me) so ...

Databinding custom XML serializable Color class in C#

I have a class, SerializableColor, to allow me to XML serialize Colors. public class SerializableColor { // omitted constructors, etc. ... [XmlIgnore] public Color Color { get { return Color.FromArgb(this.Alpha, this.Red, this.Green, this.Blue); } set { this.Alpha = value.A; ...

Is XML Serialization in .Net case sensitive?

I did not find any documentation which explicitly states whether XML serialization is case-sensitive or not. Suppose I have following class: class Test { public int Field; public string field; } Will I have any problems when XML serializing this class becuase it contains two fields having same name differing only in case? CLARIFICAT...

Can I serialize a BitArray to XML?

Hello I have a business class which I need to serialize to xml. It has a BitArray property. I have decorated it with [XmlAttribute] but the serialization is failing with To be XML serializable, types which inherit from ICollection must have an implementation of Add(System.Boolean) at all levels of their inheritance hierarchy. System.C...

Serialize a message format to xml

I have a python list as [ (A,{'a':1,'b':2,'c':3,'d':4}), B,{'a':1,'b':2,'c':3,'d':4}), ... ] I want to know if there is a standard library of serializing this kind of list to xml or should I hand code it to a file. Edit : Added Detail Assuming this is used to construct a message such that message = A( Feild att...

XStream <-> Alternative binary formats (e.g. protocol buffers)

We currently use XStream for encoding our web service inputs/outputs in XML. However we are considering switching to a binary format with code generator for multiple languages (protobuf, Thrift, Hessian, etc) to make supporting new clients easier and less reliant on hand-coding (also to better support our message formats which include bi...