xml-serialization Questions

6

I have several classes that are immutable once their initial values are set. Eric Lippert calls this write-once immutability. Implementing write-once immutability in C# usually means setting the i...
Nw asked 18/8, 2009 at 14:35

5

Solved

I have the following 2 functions: public static string Serialize(object obj) { DataContractSerializer serializer = new DataContractSerializer(obj.GetType()); MemoryStream memoryStream = new Memor...
Limemann asked 15/2, 2011 at 22:20

6

Solved

I am working on a project which generates an assembly. I just noticed that an additional assembly *.XmlSerializers.dll is being generated. Why this file is auto generated and what it is used for?
Vestiary asked 1/6, 2009 at 11:18

6

Solved

I'm writing code to do Xml serialization. With below function. public static string SerializeToXml(object obj) { XmlSerializer serializer = new XmlSerializer(obj.GetType()); using (StringWriter ...
Thiel asked 6/11, 2008 at 5:33

6

Solved

XmlElement has an "Order" attribute which you can use to specify the precise order of your properties (in relation to each other anyway) when serializing using XmlSerializer. public class bookingL...
Wristwatch asked 12/4, 2010 at 15:47

2

Solved

In all the examples I've seen of using XmlSerializer any time a list or array happens you have some sort of container element like this: <MyXml> <Things> <Thing>One</Thing&gt...
Braden asked 11/3, 2011 at 9:58

7

Solved

When i am doing Deserialize of xml i am getting "There is an error in XML document (1, 41)." . Can anyone tell me about what is the issue is all about. public static T DeserializeFromXml<T&gt...
Fritzie asked 22/3, 2012 at 11:50

9

Solved

Is it possible via an attribute of some sort to serialize a string as CDATA using the .Net XmlSerializer?
Localism asked 4/9, 2009 at 15:15

2

Solved

I am currently trying to use the XMLUnit library to compare two XML files. One of them, the candidate, is generated by my code from Java Objects (using JAXB) and the other one is the reference (I c...
Alcaraz asked 9/3, 2011 at 16:5

7

I'm refactoring some objects that are serialized to XML but need to keep a few properties for backwards compatibility, I've got a method that converts the old object into the new one for me and nul...
Fugger asked 1/12, 2008 at 14:28

3

Solved

I need to export a collection of items in camel casing, for this I use a wrapper. The class itself: [XmlRoot("example")] public class Example { [XmlElement("exampleText")] public string Example...
Kellam asked 3/1, 2013 at 16:23

21

Solved

An application I've been working with is failing when I try to serialize types. A statement like XmlSerializer lizer = new XmlSerializer(typeof(MyType)); produces: System.IO.FileNotFoundExcept...
Intemperance asked 14/7, 2009 at 19:19

11

Solved

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 xmlSeri...
Prisilla asked 12/3, 2010 at 17:24

5

Solved

I want to encode and decode binary data within an XML file (with Python, but whatever). I have to face the fact that an XML tag content has illegal characters. The only allowed ones are described i...
Bookout asked 25/6, 2013 at 15:52

5

In C#, I have a class which has a derived property that should be serialized via XML. However, XML serialization (by default) doesn't serialize read=only properties. I can work around this by defin...
Ambrogio asked 7/4, 2011 at 17:50

4

Solved

Please consider the following Amount value type property which is marked as a nullable XmlElement: [XmlElement(IsNullable=true)] public double? Amount { get ; set ; } When a nullable value typ...
Carthy asked 18/8, 2009 at 20:55

6

Solved

I am using the XmlSerializer and have the following property in a class public string Data { get; set; } which I need to be output exactly like so <Data /> How would I go about achievin...
Unreason asked 24/2, 2010 at 22:10

7

Solved

One problem bugged me enough to register on Stack Overflow. Currently if I want to serialize Color to XML string as named color, or #rrggbb, or #aarrggbb, I do it like this: [XmlIgnore()] public C...
Jews asked 19/7, 2010 at 10:48

8

Solved

Given the following XML: <?xml version="1.0"?> <user_list> <user> <id>1</id> <name>Joe</name> </user> <user> <id>2</id> &lt...

7

Solved

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...
Impending asked 14/10, 2009 at 7:13

5

I'm building a library to interface with a third party. Communication is through XML and HTTP Posts. That's working. But, whatever code uses the library does not need to be aware of the internal ...
Mattins asked 27/5, 2011 at 19:13

14

Solved

I'd like to check if an object is a number so that .ToString() would result in a string containing digits and +, -, . Is it possible by simple type checking in .NET? Like: if (p is Number) Or shou...
Involutional asked 15/7, 2009 at 10:50

5

Solved

I have been having this problem and been pulling my hair out over it. I have the followin error: Exception Details: System.NotSupportedException: Cannot serialize member HannaPrintsDataAccess.Cu...
Marianomaribel asked 3/9, 2010 at 2:51

6

Solved

I have an object Foo which I serialize to an XML stream. public class Foo { // The application version, NOT the file version! public string Version {get;set;} public string Name {get;set;} } ...
Crosson asked 12/9, 2011 at 9:42

3

Solved

I'm using XmlSerializer to serialize an object that contains a generic list List <ChildBase> Children {get;set} The problem is that each element derives from ChildBase which in fact is an abs...
Chic asked 29/10, 2009 at 11:41

© 2022 - 2025 — McMap. All rights reserved.