XML Deserialization is the process of re-creating an in-memory object from its serialized state which used XML as a data format.
Questions tagged [xml-deserialization]
1004 questions
18
votes
3 answers
How to define multiple names for XmlElement field?
I have a XML document provided by client applications to my C# application. This is how a client sends the XML file:
2380983
And…

Luiggi Mendoza
- 85,076
- 16
- 154
- 332
16
votes
2 answers
Using XML decorations to specify default values during de-serialization
I have a problem deserializing some XML; the XML supplied by a third party is quite verbose, so if there is no value set for an particular element, it will supply and empty element (e.g. ).
This is a problem for certain elements, for…

CJM
- 11,908
- 20
- 77
- 115
16
votes
3 answers
Parsing XML with references to previous tags, and with children corresponding to subtypes of some class
I have to deal with (a variation of) the following scenario. My model classes are:
class Car {
String brand;
Engine engine;
}
abstract class Engine {
}
class V12Engine extends Engine {
int horsePowers;
}
class V6Engine extends Engine…

aioobe
- 413,195
- 112
- 811
- 826
14
votes
3 answers
Deserialize multiple XML elements with the same name through XmlSerializer class in C#
I have an XML in the form
0
0
0
1
0
…

shobhit
- 461
- 2
- 6
- 14
14
votes
4 answers
Deserialization error in XML document(1,1)
I have an XML file that I deserialize, the funny part is the XML file is the was serialized
using the following code:
enter code here
var serializer = new XmlSerializer(typeof(CommonMessage));
var writer = new…

jprbest
- 717
- 6
- 15
- 32
13
votes
1 answer
XML With SimpleXML Library - Performance on Android
I'm using the Simple XML library to process XML files in my Android application. These file can get quite big - around 1Mb, and can be nested pretty deeply, so they are fairly complex.
When the app loads one of these files, via the Simple API, it…

Jonskichov
- 299
- 4
- 15
13
votes
2 answers
Deserialize XML element presence to bool in C#
I'm trying to deserialize some XML from a web service into C# POCOs. I've got this working for most of the properties I need, however, I need to set a bool property based on whether an element is present or not, but can't seem to see how to do…

James Simm
- 1,569
- 1
- 16
- 28
12
votes
2 answers
When is the class constructor called while deserialising using XmlSerializer.Deserialize?
My application saves a class away using XmlSerializer, and then later when required, creates an instance by deserialising it again.
I would like to use some property members of my class (assigned during deserialisation) in my constructor logic. It…

Satyajit
- 523
- 4
- 17
11
votes
2 answers
C# There is an error in XML document (2, 2)
I'm trying to deserialize the following XML :
Message id '1' was already submitted.
through this call :
[...]
var x =…

Serge
- 6,554
- 5
- 30
- 56
10
votes
1 answer
C# XML serialization backwards compatibility
Previously, the serialization/deserialization methods used the type Item:
public class Item{}
Now I have a new class called ItemWrapper derived from Item with an additional property:
public class ItemWrapper : Item
{
public string NewProperty {…

jsirr13
- 944
- 2
- 12
- 38
10
votes
2 answers
XML deserialization generic method
I have next XML file:
d639a54f-baca-11e1-8067-001fd09b1dfd
-24145
e3b3b4cd-bb8e-11e1-8067-001fd09b1dfd
…

algreat
- 8,592
- 5
- 41
- 54
9
votes
2 answers
Deserialize Xml with empty elements
Consider the following XML:
2
I need to deserialize this xml to an object. So, i wrote the following class.
public class A
{
[XmlElement("b", Namespace = "")]
public int? B { get; set; }
…

Zé Carlos
- 3,627
- 5
- 43
- 51
9
votes
3 answers
XML-Deserialization of double value with German decimal separator in C#
i'm trying to deserialize a Movie object from a "German" xml string:
string inputString = ""
+ ""
+ "5 "
+ "1,99 " // <-- Price with German…

Daniel Kutik
- 6,997
- 2
- 27
- 34
9
votes
2 answers
XML Deserialization with Servicestack.Text
I am learning Servicestack.Text Library as it has some of the best features.I am trying to deserialize XML into one of my DTOs as below;
C# Code:[Relevant Code with Console Application Here]
class Program
{
static void Main(string[]…

Bhushan Firake
- 9,338
- 5
- 44
- 79
8
votes
1 answer
C# deserializing xml with multiple possible namespaces
I created an API wrapper class library for consuming a rest API from a 3rd party.
It was all working until they recently updated the API in the latest version of their product and added a namespace to the root element, now my deserialization code is…

Adam
- 168
- 5