This tag refers to serialization technologies which use XML as a data format.

learn more… | top users | synonyms (1)

87
votes
3answers
29k views

Proper way to implement IXmlSerializable?

Once a programmer decides to implement IXmlSerializable, what are the rules and best practices for implementing it? I've heard that GetSchema() should return null and ReadXml should move to the next ...
53
votes
3answers
39k views

Why XML-Serializable class need a parameterless constructor

I'm writing code to do Xml serialization. With below function. public static string SerializeToXml(object obj) { XmlSerializer serializer = new XmlSerializer(obj.GetType()); using ...
59
votes
8answers
26k views

XML Serialization and Inherited Types

following on from my previous question I have been working on getting my object model to serialize to XML. But I have now run into a problem (quelle surprise!). The problem I have is that I have a ...
94
votes
19answers
47k views

.NET XML serialization gotchas? [closed]

I've run into a few gotchas when doing C# XML serialization that I thought I'd share: You can't serialize items that are read-only (like KeyValuePairs) You can't serialize a generic dictionary. ...
34
votes
8answers
29k views

Generating an Xml Serialization assembly as part of my build

This code produces a FileNotFoundException, but ultimately runs without issue: void ReadXml() { XmlSerializer serializer = new XmlSerializer(typeof(MyClass)); //... } Here is the exception: ...
52
votes
7answers
27k views

Why isn't there an XML-serializable dictionary in .NET?

I need an XML-serializable dictionary. Actually, I now have two quite different programs that need one. I was rather surprised to see that .NET doesn't have one. I asked the question elsewhere and ...
21
votes
4answers
46k views

JAXB: How to ignore namespace during unmarshalling XML document?

My schema specifies a namespace, but the documents don't. What's the simplest way to ignore namespace during JAXB unmarshalling (XML -> object)? In other words, I have ...
58
votes
12answers
22k views

XmlSerializer giving FileNotFoundException at constructor

An application I've been working with is failing when i try to serialize types. A statement like this: XmlSerializer lizer = new XmlSerializer(typeof(MyType)); Produces: ...
21
votes
9answers
48k views

How do I map XML to C# objects

I have an XML that I want to load to objects, manipulate those objects (set values, read values) and then save those XMLs back. It is important for me to have the XML in the structure (xsd) that I ...
51
votes
3answers
25k views

XmlSerializer: remove unnecessary xsi and xsd namespaces

Is there a way to configure the XmlSerializer so that it doesn't write default namespaces in the root element? What I get is this: <?xml ...> <rootelement xmlns:xsi="..." ...
21
votes
4answers
21k views

Omitting all xsi and xsd namespaces when serializing an object in .NET?

The code looks like this: StringBuilder builder = new StringBuilder(); XmlWriterSettings settings = new XmlWriterSettings(); settings.OmitXmlDeclaration = true; using (XmlWriter xmlWriter = ...
20
votes
9answers
75k views

XML Serialize generic list of serializable objects

Can I serialize a generic list of serializable objects without having to specify their type. Something like the intention behind the broken code below: List<ISerializable> serializableList = ...
30
votes
3answers
16k views

How do you serialize a string as CDATA using XmlSerializer?

Is it possible via an attribute of some sort to serialize a string as CDATA using the .Net XmlSerializer?
33
votes
4answers
38k views

Using StringWriter for XML Serialization

I'm currently searching for an easy way to serialize objects (in C# 3). I googled some examples and came up with something like: MemoryStream memoryStream = new MemoryStream ( ); XmlSerializer xs = ...
12
votes
1answer
10k views

XML Serialization and namespace prefixes

I'm looking for a way with C# which I can serialize a class into XML and add a namespace, but define the prefix which that namespace will use. Ultimately I'm trying to generate the following XML: ...

1 2 3 4 5 29
15 30 50 per page