Questions tagged [xml-serialization]

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

This tag refers to serialization technologies which use XML as a data format. In the context of .NET, it refers to the XmlSerializer class, less so to the DataContractSerializer class, still less to the SoapFormatter class.

4687 questions
2
votes
2 answers

C# hierarchy of dictionaries to xml string?

Please show me how to serialize object of type IEnumerable>. This object do not contain custom structs, but it can (not must) contain another objects (values) of type IEnumerable>. As for…
Edward83
  • 6,664
  • 14
  • 74
  • 102
2
votes
0 answers

Serialization error after converting solution from .NET 4.0 to .NET 4.6.1

We have recently updated our solution from Visual Studio 2010 to VS 2017 & .NET Framework 4.0 to 4.6.1. There are no changes in database which is running on Postgres 9.4. This also included upgrading Npgsql DLL from version 2 to version 3. We have a…
Arun
  • 2,217
  • 3
  • 17
  • 18
2
votes
1 answer

Serializing a class under a different element name

I have this class: [XmlRoot(ElementName ="Lesson")] public class LessonOld { public LessonOld() { Students = new List(); } public string Name { get; set; } public DateTime FirstLessonDate { get; set; } public…
derekantrican
  • 1,891
  • 3
  • 27
  • 57
2
votes
2 answers

How do I (de)serialize a serializable dictionary with string array values?

I need to (de)serialize a class in C# (.NET Framework 4.5.2) to and from XML which has a dictionary property with string keys and string[] array values. I am using the SerializableDictionary implementation mentioned in this answer on…
Knowledge Cube
  • 990
  • 12
  • 35
2
votes
2 answers

XML vs. object trees

In my current project (an order management system build from scratch), we are handling orders in the form of XML objects which are saved in a relational database. I would outline the requirements like this: Selecting various details from anywhere…
Elbonian
  • 1,118
  • 2
  • 12
  • 17
2
votes
1 answer

DataContract not using Name property specified in attribute

I don't know what serializer is being used but I'm seeing some inconsistent behavior during serialization when using the Name property of the datacontract attribute. Here's an example of what I'm doing: [XmlRoot(ElementName =…
Jason Levens
  • 194
  • 1
  • 10
2
votes
1 answer

xmlns attribute not produced for nested elements

I have a class with a nested list of another class, like this: public class Departement { [XmlElement (Namespace = "http://tempuri.org/")] string Id; [XmlElement (Namespace = "http://tempuri.org/")] List listStident =…
AHB
  • 43
  • 3
2
votes
0 answers

How to ignore a property of instance gets serialized?

I’m using DataContractSerializer for serialization/deserialization. I need to ignore a particular property of an instance gets serialized which used as a property in another class. Here I have provided the simple code structure for your references.…
2
votes
2 answers

Keep sort when deserialize and serialize XML using XmlSerializer

I have the following test XML string: b1 a2 a1 b2 which I deserialize using this class: [XmlRoot(ElementName = "test")] public class Test { …
CrazyTea
  • 297
  • 1
  • 3
  • 13
2
votes
5 answers

TextWriter not writing all files

I've got written a service that has a separate thread running that reads roughly 400 records from a database and serializes them into xml files. It runs fine, there are no errors and it reports all files have been exported correctly, yet only a…
Iain Ward
  • 9,850
  • 5
  • 34
  • 41
2
votes
1 answer

XML-Serialize a derived class without having access to either the base class OR the serializer instance?

I am writing a plugin for an application that exposes an abstract base class type, and from which my class is supposed to be derived. When it stores my instantiated class away for later retrieval, the application uses its XML serializer to serialize…
Satyajit
  • 523
  • 4
  • 17
2
votes
1 answer

How do I change the XmlElement name dynamically?

[XmlRoot("A")] public class Foos { [XmlElement("A1")] public List FooList{ get; set; } } var serializer = new XmlSerializer(typeof(Foos)); This code working as well. But its not dynamic. I want [XmlRoot("A")] to…
Muhammet Can TONBUL
  • 3,217
  • 3
  • 25
  • 37
2
votes
1 answer

Create file using XmlSerializer: FileStream or XmlWriter?

I usually use this kind of code to serialize an object graph to XML: var ser = new XmlSerializer(myObject.GetType()); using(var stream = new FileStream(filename, FileMode.Create)) { ser.Serialize(stream , myObject); } (Error handling removed for…
Serge Wautier
  • 21,494
  • 13
  • 69
  • 110
2
votes
2 answers

serialization of class into XML C#

I'm Having Below Class i.e ReconciliationRequest.cs using System; using System.Collections.Generic; using System.Xml.Serialization; [XmlRoot("ReconciliationRequest")] [Serializable] public class ReconciliationRequest { public List
shweta
  • 319
  • 2
  • 8
  • 21
2
votes
0 answers

Memory leak using XmlSerializer on .net core 2.0 linux

After lots of research and trial an error. I finally figure out where my memory leak was coming from. You need to use XmlSerializer as a static object. Memory Leak using StreamReader and XmlSerializer private string Serialize(Bob request) …
TheBoz
  • 61
  • 2