xml-serialization

In .NET XML deserialization, how can I allow polymorphic use of Array types ?

Example Schema: <complexType name="Dog">...</complexType> <complexType name="Cat">...</complexType> <complexType name="ArrayOfDog"> <sequence> <element name="Dog" type="tns:Dog minOccurs="0" maxOccurs="unbounded" /> </sequence> </complexType> <complexType name="Foo"> <sequence> <element name="Bar" type="str...

There is any tool that creates a class from a XML for deserialization? (C# .NET)

I have this XML file, and I want to deserialize it to an object. But I don't want to type its class definition. There is any tool that can create the C# code of the class for me, inferring the data types from sample data? ...

POJO to an XML string in Google App Engine?

I would like to create a REST interface for my Java Google App Engine program. I figured I would start by generating some XML from my POJOS. However, it seems that XStream is bitten by GAE's restrictions. What can I use to generate an XML string in Google App Engine? Thanks. Edit 1: Here is the beginning of the exception: javax.servl...

How to add attributes for C# XML Serialization

Hi, I am having an issue with serializing and object, I can get it to create all the correct outputs except for where i have an Element that needs a value and an attribute. Here is the required output: <Root> <Method>Retrieve</Method> <Options> <Filter> <Times> <TimeFrom>2009-06-17</TimeFrom> </Times> <...

¿What is the best way to Create a Xml Document conforming to a XSD Schema?

Well, I have a XSD and I have to generate a XML document for send to the customers of the company I work with. The Documents I send will be validated against this XSD schema. What is the best way to Create a Xml Document conforming to a XSD Schema? I mean, i'm searching for best practices and the like. I'm new to this and "googling" aro...

XmlSerializer.Serialize ambiguous.

I have create testing application that has 3 classes Car Radio SportCar : Car (has a Radio) As the serialize process when I create instance of XmlSerializer object I use 2 object to testing XmlSerializer xmlSerializer = new XmlSerializer(typeof(SportCar)); and XmlSerializer xmlSerializer = new XmlSerializer( typeof(SportCar),...

.NET Serialization Ordering

Hi, I am trying to serialize some objects using XmlSerializer and inheritance but I am having some problems with ordering the outcome. Below is an example similar to what I have setup: ~ public class SerializableBase { [XmlElement(Order = 1)] public bool Property1 { get; set;} [XmlElement(Order = 3)] public bool Prope...

Serialize Python dictionary to XML

Hi, There is simple JSON serialization module with name "simplejson" which easily serializes Python objects to JSON. I'm looking for similar module which can serialize to XML. Thank you ...

Web Service: Specifying XML Serialization element names for generic types

I've created a web service that uses a generic type Response<TCode, TData> and so I'm ending up with elements like ResponseOfResponseCodeUserData ResponseOfResponseCodeArrayOfRightData etc. Functionally works just fine but I'm wondering if there's a way to name these particular elements? EDIT: Here's an example. [return: XmlEleme...

How to (xml) serialize a uri

I have a class I've marked as Serializable, with a Uri property. How can I get the Uri to serialize/Deserialize without making the property of type string? ...

Can I apply an attribute to an inherited member?

Suppose I have the following (trivially simple) base class: public class Simple { public string Value { get; set; } } I now want to do the following: public class PathValue : Simple { [XmlAttribute("path")] public string Value { get; set; } } public class ObjectValue : Simple { [XmlAttribute("object")] public str...

XML file interpretation and manipulations

<?xml version="1.0" encoding="utf-8" ?> <root> <MyData> <MyField>SomeValueHere1</MyField> <MyComplexData> <MyComplexDataField1 property="1"></MyComplexDataField1> <MyComplexDataField2 someproperty"value1"> value1 </MyComplexDataField1> </MyComplexData> </MyData> <MyData> <MyField>SomeValueHere11</MyField...

Serialize nullable fields from an object c#

I am trying to serialize an object that has nullable fields. If the field doesn't have any data in it the field is dropped from the serialized output. Any suggests on how to work around this? Is there a way to specify that nullable empty fields still get carried over? This occurs when "propertyname_specified = false" ...

returning Abstract Types through REST

I am trying to build a rest service that will return some data that is a collection of an abstract class which contains various implementation classes. How do i set up my REST return type to be able to specify the various types that will be returned. for instance. <RootType> <dataAttribute></dataAttribute> <Array> <ItemofClassA></I...

IXmlSerializable, reading xml tree with many nested elements

Could you guys give me an example how to read and write from/to xml like this: <Foolist> <Foo name="A"> <Child name="Child 1"/> <Child name="Child 2"/> </Foo> <Foo name = "B"/> <Foo name = "C"> <Child name="Child 1"> <Grandchild name ="Little 1"/> </Child> </Foo> <Foolist> ...

How do I add a attribute to a XmlArray element (XML Serialization)?

How do I add a attribute to a XmlArray element ( not to XmlArrayItem ) while serializing the object? Thanks and regards 123Developer ...

XmlAttributeOverrides further customization

XmlAttributeOverrides is a good way to override some attributes for serialization. MSDN says: You can control and augment the serialization of objects found in a DLL, even if you do not have access to the source And I have a question is it possible to implement some custom algorithm with XmlAttributeOverrides? For example if you want t...

SGEN, InternalsVisibleTo and assembly signing

Hi, I'm trying to do something a bit unusual... I have this class Foo : public class Foo { public Foo(string name) { this.Name = name; } internal Foo() { } public string Name { get; internal set; } public int Age { get; set; } } Notice the internal setter for Name, and the internal default c...

Associating Windows Forms TreeView items to actual data

So - working with C# and Windows Forms, I have a bunch of "Task" classes. Every class has a List<Task>, so that they can have any number of children (and the children can obviously have more children...) These tasks are stored in a "Project" class (in a List<Task>, obviously), which is then serialized to XML. I have a function to recurs...

Is there a way to make sure Dispose() is called on exception during deserialization of an IDisposable class?

in c#, i am deserializing an object of a type that implements IDisposable with the following statement (for illustration only). XmlSerializer s = new XmlSerializer(typeof(MyDisposable)) MyDisposable o = (MyDispoable)s.Deserialize(filepath); afaik, the serializer tries to construct the object using the default ctor and assigning all pu...