xml-serialization

create XmlSerializer in MFC C++

Hi, I want to implement in my MFC application project this logic, which written in C# looks like: XmlSerializer ser = new XmlSerializer(typeof(A_CLASS)); StringBuilder sb = new StringBuilder(); XmlWriterSettings sett = new XmlWriterSettings(); sett.Indent = true; sett.IndentChars = "\t"; using (XmlWriter sw = XmlWriter.Create(sb,...

setting new default properties for to_xml serializer in Rails

In Rails, I'm coding a series of controllers to generate XML. Each time I'm passing a number of properties in to to_xml like: to_xml(:skip_types => true, :dasherize => false) Is there a way I can set these as new default properties that will apply whenever to_xml is called in my app so that I don't have to repeat myself? ...

Is there a way to do object (with its attributes) serializing to xml?

Create a class (call it FormElement). That class should have some properties like the metadata they have with data elements (name, sequence number, value—which is just a string, etc). This class has as attributes of type Validation Application Block Validation classes. I want to serialize it to xml and deserialize it. Verify that all...

Why doesn't the XmlSerializer need the type to be marked [Serializable]?

In C#, if I want to serialize an instance with XmlSerializer, the object's type doesn't have to be marked with [Serializable] attribute. However, for other serialization approaches, such as DataContractSerializer, needs the class be marked as [Serializable] or [DataContract]. Is there any standard or pattern about serialization requirem...

TClientDataset: 'Fieldtype not supported for XML.'

I've got a bunch of data loaded into a TClientDataset, representing an array of complex objects. But when I try to run Dataset.SaveToFile('c:\test.xml', dfXMLUTF8); it doesn't like it: Project testing.exe raised exception class EDBClient with message 'Fieldtype not supported for XML.'. This is a lot less useful than it should be, f...

Data Strategies in Windows Mobile

I'm developing a C# application on Windows Mobile, and like most of my WM applications, I always get bogged down whenever I'm deciding on a serialization strategy. In the desktop world, I'm not too worried about it because i've already developed a pretty robust custom xml serializer - however, in the WM world, I don't want to use it be...

.Net XmlSerializer: deserialize CDATA being inner text

Hello, I have a problem with CDATA deserialization using standard .Net XmlSerializer. Update: I get XML from external system and I can't influence it's format so I can't make CData be enclosed in a separate Element of Attribute. Serialization gives this: <?xml version="1.0" encoding="utf-16"?> <MyClass xmlns:xsi="http://www.w3.org/20...

Can you control the depth of DataContractSerializer deserialization?

I have a pretty sizeable object graph that I have serialized to a file via the DataContractSerializer. I now want to present a list of these files to the user to choose from. In this list, I want to show some of the details about the file, which are properties of the root object. I don't want to load the whole graph into memory, since...

XML Serialization empty collections not self closing

Wondering if anyone can help me with this annoying but trivial (in terms of need) question. I have an object which has inside it a collection of object public class OuterClass { InnerClasses innerClasses= new InnerClasses(); public InnerClasses InnerClasses { get {return innerClasses; } } public string Name...

XmlSerializer, sgen.exe and generics

I have a generic type: public class Packet<T> where T : IContent { private int id; public int Id { get { return this.id; } } private T content; public T Content { get { return this.content; } } } I want to deserialize/serialize instances of this type from/to XML. IContent is defined like that: public interface IConte...

XML Deserialization - convert attribute value into class automatically (.net)

(vb.net/c#/etc) I am having trouble figuring out how to do a bit of deserialization magic. Currently the standard deserialization works fine, including the enums, but now I want to convert an attribute into a class. Oh! what was I thinking! My xml looks a bit like this: .... <review user="..." version="2.2">...</review> And this f...

Using XmlSerializer with private and public const properties

What's the simplest way to get XmlSerializer to also serialize private and "public const" properties of a class or struct? Right not all it will output for me is things that are only public. Making it private or adding const is causing the values to not be serialized. ...

How to add external data to an XML?

I've got an XML Schema and an XML instance that is valid to that schema. This XML instance contains some data. I'd like to extend the XML instance with further data(my own meta-data per XML element in the XML instance) while keeping it valid to the provided schema. The real use-case is that I've my own control that gets its data via X...

Deep xml serialize a struct Options

Hi, I have the class and struct shown below. If I serialize the class as is using xmlserializer I get: < Test> < TestNumber1 >5< /TestNumber1 > < InnerTest / > < /Test > what is the easiest way to make InnerTest serialise properly (preferably using xmlserializer) with out giving the Number property a setter? Thanks, Nick ...

XmlSerialization of mutiple object types in the one list

I have an object that has a list of abstract 'aninamls'. i.e. var animals = new Animals { new Bird{ TailFeatherColour = "Blue" }, new Cat{ Colour = "Brown" } }; using the xmlserializer, is it possible to serialize the above to the following xml, <?xml version="1.0" encoding="utf-16"?> <Animals> <Bird> <TailFeatherC...

Null characters in web service response causes XML document error

It seems there is a bug in SQL Server Integration Services 2005 which, in certain circumstances, converts a zero length string into a single character string whose character happens to be an ansi null, ie. ascii character zero (Please note that this is very different from a sql null). This happens to one of our data load processes so th...

How to deserialize an XML doc with a prefixed namespace but no ns-prefixed elements?

I have an XML document from an external source. <?xml version="1.0" encoding="utf-8"?> <ns0:Info xmlns:ns0="http://www.ZomboCorp.com/"&gt; <Name>Anthony</Name> <Job>Developer</Job> </ns0:Info> I need to deserialize it into an object like this. public class Info { public String Name { get; set; } public String Job { get; ...

XmlSerializer and InternalsVisibleTo attribute

Is it possible to make XmlSerializer serialize internal class members by using InternalsVisibleTo attribute? If it is, what assembly should I make my internals visible to. In other words, what assembly name and public key should I provide to the InternalsVisibleTo attribute. ...

XmlSerializer - same element with differrent attribute

Hi I have xml containing : <day p="d"> <day p="n"> What attributes do I need to add to Day class in order to deserialize the xml with XmlSerializer? ...

XmlSerialization Collection as Array

I'm trying to serialize a custom class that needs to use multiple elements of the same name. I've tried using xmlarray, but it wraps them in another elements. I want my xml to look like this. <root> <trees>some text</trees> <trees>some more text</trees> </root> My code: [Serializable(), XmlRoot("root")] public class test...