Questions tagged [xml-deserialization]

XML Deserialization is the process of re-creating an in-memory object from its serialized state which used XML as a data format.

1004 questions
534
votes
16 answers

How to Deserialize XML document

How do I Deserialize this XML document: 1020 Nissan Sentra 1010
Alex
  • 39,265
  • 21
  • 45
  • 42
181
votes
20 answers

How to convert an XML string to a dictionary?

I have a program that reads an XML document from a socket. I have the XML document stored in a string which I would like to convert directly to a Python dictionary, the same way it is done in Django's simplejson library. Take as an example: str…
user361526
  • 3,333
  • 5
  • 25
  • 36
168
votes
8 answers

Is it possible to deserialize XML into List?

Given the following XML: 1 Joe 2 John And the following class: public class User { …
Daniel Schaffer
  • 56,753
  • 31
  • 116
  • 165
147
votes
2 answers

How to deserialize xml to object

Name1 Desc1 Name2 Desc2 I have this XML, How should i model the Class so i will be able to deserialize it using…
user829174
  • 6,132
  • 24
  • 75
  • 125
54
votes
8 answers

Unable to generate a temporary class (result=1). error CS0030: Cannot convert type 'Type[]' to 'Type'?

I get this error after I created a class from my xsd file using the xsd.exe tool. So I searched the net and found a solution. Here is the link: http://satov.blogspot.com/2006/12/xsdexe-generated-classes-causing.html Problem is that this makes the…
grady
  • 12,281
  • 28
  • 71
  • 110
50
votes
1 answer

using XmlArrayItem attribute without XmlArray on Serializable C# class

I want XML in the following format: ... ...
Sarah Vessels
  • 30,930
  • 33
  • 155
  • 222
50
votes
2 answers

Deserializing XML from String

I'm trying to convert the result I get from my web service as a string and convert it to an object. This is the string I'm getting from my service: 2013-01-31T15:28:13.2847259ZThe…
disasterkid
  • 6,948
  • 25
  • 94
  • 179
36
votes
2 answers

How to ignore unused XML elements while deserializing a document?

I'm using SimpleXml to (de)serialize POJOs. Now, I have a big XML which has some elements which are not needed. For instance, with this XML: Used Not used I want to create a POJO which…
Cristian
  • 198,401
  • 62
  • 356
  • 264
22
votes
5 answers

How do I use an XmlSerializer to deserialize an object that might be of a base or derived class without knowing the type beforehand?

In C#, how do I use an XmlSerializer to deserialize an object that might be of a base class, or of any of several derived classes without knowing the type beforehand? All of my derived classes add additional data members. I've made a simple GUI that…
8bitcartridge
  • 1,629
  • 6
  • 25
  • 38
22
votes
3 answers

Error when deserializing xml to an object: System.FormatException Input String was not in correct format

Hello and thanks in advance for the help. I am having an issue when trying to deserialize an XElement into an object using an XmlSerializer and a StringReader. My code to deserialize is this: /*deseierialize a single RegisterServerObject instance…
Christian
  • 1,685
  • 9
  • 28
  • 48
21
votes
1 answer

Deserialize XElement into Class(s)

I am trying to Deserialize an XML file into a few class objects: Artist, Album, and Songs Here is the current setup: static void Main(string[] args) { var riseAgainst = DeSerializer(CreateElement()); Console.WriteLine(string.Format("Band:…
Alex
  • 2,114
  • 9
  • 25
  • 34
21
votes
1 answer

How to Deserialize XML using DataContractSerializer

I'm trying to deserialize an xml document: TEST1 TESTGAME1 1111111
ShaneKm
  • 20,823
  • 43
  • 167
  • 296
20
votes
2 answers

Why does the OnDeserialization not fire for XML Deserialization?

I have a problem which I have been bashing my head against for the better part of three hours. I am almost certain that I've missed something blindingly obvious... I have a simple XML file:
Jonathan
  • 25,873
  • 13
  • 66
  • 85
19
votes
1 answer

C# - Xml Element with attribute and node value

I have some Xml that I need to deserialize into an object. The Xml is: Bob and the classes are: public class Person { public Type Type; } public class Type { [XmlAttribute("id")] public string id; …
dotNetkow
  • 5,053
  • 4
  • 35
  • 50
18
votes
5 answers

deserializing enums

I have an xml in which one of the elements has an attribute that can be blank. For e.g., ..... Now, language is enum type in the classes created from the schema. It works fine if the language is…
genericuser
  • 1,430
  • 4
  • 22
  • 40
1
2 3
66 67