tagged [xml-serialization]

How can I make the xmlserializer only serialize plain xml?

How can I make the xmlserializer only serialize plain xml? I need to get plain xml, without the `` at the beginning and `xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3....

Can I make XmlSerializer ignore the namespace on deserialization?

Can I make XmlSerializer ignore the namespace on deserialization? Can I make XmlSerializer ignore the namespace (xmlns attribute) on deserialization so that it doesn't matter if the attribute is added...

How to XML-serialize a dictionary

How to XML-serialize a dictionary I have been able to serialize an IEnumerable this way: However, I realised that now I need a dictionary containing a collection

Using XmlSerializer to serialize derived classes

Using XmlSerializer to serialize derived classes I'm using XMLSerializer to serialize an object that contains a generic list `List Children {get;set}` The problem is that each element derives from `Ch...

29 Oct at 11:53

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

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...

xmlserializer validation

xmlserializer validation I'm using XmlSerializer to deserialize Xml achives. But I found the class xsd.exe generated only offers capability to read the xml, but no validation. For example, if one node...

10 Nov at 03:14

How can I skip xml declaration when serializing?

How can I skip xml declaration when serializing? I'm trying to output a xml file without xml head like I tried: But it's still out

17 Feb at 17:41

xml serialization specify xmlelement and xmlattribute together

xml serialization specify xmlelement and xmlattribute together Given :- When serialized to XML will give ``` Some Publisher XYZ123

29 Sep at 16:16

How to keep XmlSerializer from killing NewLines in Strings?

How to keep XmlSerializer from killing NewLines in Strings? Suppose I have a simple Class with just one Member a String. Now when I serialize and then deserialize it with the questionable XmlSerialize...

26 Feb at 07:55

xmlns=''> was not expected. - There is an error in XML document (2, 2)

xmlns=''> was not expected. - There is an error in XML document (2, 2) Im trying to deserialize the response from [this simple web service](http://inb374.jelastic.tsukaeru.net:8080/VodafoneDB/webresou...

1 Oct at 11:38

Xml Serialization vs. "True" and "False"

Xml Serialization vs. "True" and "False" I'm having an issue with deserializing an XML file with boolean values. The source XML files I'm deserializing were created from a VB6 app, where all boolean v...

23 Apr at 08:40

Generic deserialization of an xml string

Generic deserialization of an xml string I have a bunch of different DTO classes. They are being serialized into an XML string at one point and shot over to client-side of the web app. Now when the cl...

Force XML serialization to serialize readonly property

Force XML serialization to serialize readonly property 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 r...

7 Apr at 17:50

Serialize char data type with XmlSerializer

Serialize char data type with XmlSerializer I have a class which has property whiches type is char as following When value of TestProperty is 'N' and if I serialize TestClass it will produce following...

17 Apr at 07:28

How to include null properties during xml serialization

How to include null properties during xml serialization Currently, the code below omits null properties during serialization. I want null valued properties in the output xml as empty elements. I searc...

29 Aug at 15:58

What types of Exceptions can the XmlSerializer.Deserialize method throw?

What types of Exceptions can the XmlSerializer.Deserialize method throw? For this method, `XmlSerializer.Deserialize`, what kinds of exception may be thrown? `XmlException`? `InvalidOperationException...

XML Serialization question - How to Serialize Element, Attribute and Text from One Object

XML Serialization question - How to Serialize Element, Attribute and Text from One Object I'm new into XML Serialization using .NET and after working with it for some time I'm quite fuzzled now. I can...

28 Apr at 09:55

Should I make this XmlSerializer static?

Should I make this XmlSerializer static? I've got a class which uses an `XmlSerializer` in its `Read/WriteXml` methods. The Serializer is currently `private readonly`. ``` public class Foo : IXmlSeria...

16 Jul at 07:51

Serialization of unprintable character

Serialization of unprintable character The following code; Throws this exception in .NET 4. > Invalid Operation Exception - There is an

How do I deserialize XML into an object using a constructor that takes an XDocument?

How do I deserialize XML into an object using a constructor that takes an XDocument? I have a class: I would like to be able to use an XMLSeralizer to Deserialize an XDocument directly in the construc...

How do I Set XmlArrayItem Element name for a List<Custom> implementation?

How do I Set XmlArrayItem Element name for a List implementation? I want to create a custom XML structure as follows: I've created an implementation of `List` just to be able to do this. My code is as...

24 Nov at 09:10

.NET XML Serialization and inheritance

.NET XML Serialization and inheritance I have structure like this: List contains objects of type B and C they also have some fields that I would like to keep, can I now serialize it, deserialize back ...

.net XmlSerializer on overridden properties

.net XmlSerializer on overridden properties I have a base class with an abstract property: now, I have a subclass, which is XmlSerialized. So, it has: I cannot move the XmlElement attribute to basecla...

Serialize Property as Xml Attribute in Element

Serialize Property as Xml Attribute in Element I have the following class: Which (when populated with some test data) and Serialized using XmlSerializer.Serialize() results in the f

4 Jul at 14:4

Serializing an object as UTF-8 XML in .NET

Serializing an object as UTF-8 XML in .NET Proper object disposal removed for brevity but I'm shocked if this is the simplest way to encode an object as UTF-8 in memory. There has to be an easier way ...

5 Oct at 08:40