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
3 answers

How to convert this XML Definition into a C# Class

Is there a 'standard' way to convert something like this into a set of C# classes?
Rudi
  • 3,124
  • 26
  • 35
2
votes
1 answer

Discrepancies in deserialization of valid xml files with System.Xml.Serialization.XmlSerializer

A fairly involved question, so thanks in advance. The following two xml files both validate against the given schemas, but on attempting to deserialize using .Net's XmlSerializer only the first does so correctly:
Iain Sproat
  • 5,210
  • 11
  • 48
  • 68
2
votes
0 answers

Return XML response with metadata from asp .net core Web API

How can I return an XML response from webAPI written in .net core to have the metadata information at the top. Required response :
Rohit Vipin Mathews
  • 11,629
  • 15
  • 57
  • 112
2
votes
2 answers

Object xml deserialization issue?

My objects has a parent-child relationship. Each child object has a Parent property pointing to its container. When this object is created in the app, it's set, and thus no problem. This Parent property is marked with XmlIgnore attribute, because it…
newman
  • 6,841
  • 21
  • 79
  • 126
2
votes
1 answer

XML Serialization of List growing too large

I have a C# Windows forms application that runs a Trivia game on an IRC channel, and keeps the questions it asks, and the Leaderboard (scores) in Classes that I serialize to XML to save between sessions. The issue I have been having is best…
Jeremy
  • 23
  • 4
2
votes
3 answers

Is it possible to persist a state machine built in Workflow Foundation to a DB using Nhibernate?

I have an application which contains multiple state machine instances when running. I would like these to be implicitly persisted to a database in order that if the application is restarted, they can be re-loaded from the database and they will…
rvxnet
  • 457
  • 5
  • 16
2
votes
6 answers

Using the .NET serializer to serialize XML to a .NET class

I have an XML file: And a C# object: Public Class Product { [XmlAttribute] Public Name {get; set;} } Using the .NET…
Bob
  • 21
  • 1
2
votes
3 answers

Can you control the depth of DataContractSerializer deserialization?

I have a pretty sizeable object graph that I have serialized to a file via the DataContractSerializer. I now want to present a list of these files to the user to choose from. In this list, I want to show some of the details about the file, which…
Mel
  • 2,337
  • 19
  • 25
2
votes
1 answer

Conditional XML serialization of list items

I would like to know if one can conditionally exclude items in a list from being serialized using the ShouldSerialize* pattern. For example take the two classes: public class Product{ public int ID {get; set;} public List ProductSyles…
Neomoon
  • 181
  • 1
  • 3
  • 12
2
votes
0 answers

C# Serialize EventArgs to Xml

I am trying to serialize an object that contains an EventArgs object. If I ignore the EventArgs object upon serialization, everything works fine, but if I don't put an [XmlIgnore] above it, the application crashes with the error…
ashurexm
  • 6,209
  • 3
  • 45
  • 69
2
votes
1 answer

.NET serialization: Best practice to map classes to elements and properties to attributes?

I'm trying to serialize the following object: [XmlRoot("book")] public class Book { #region Properties [XmlAttribute("isbn-10")] public string Isbn10 { get; set; } [XmlAttribute("isbn-13")] public string Isbn13 { get; set; } …
Nano Taboada
  • 4,148
  • 11
  • 61
  • 89
2
votes
4 answers

Serialize and DeSerialized derived classes from the base class

I am trying to create a base class where I can inherit from it (to add properties to the derived classes) and the utilized the Load and Save methods from the base class. I find myself writing the Load and Save over and over and I'd like to apply…
Julian Easterling
  • 830
  • 1
  • 10
  • 21
2
votes
1 answer

Unable to position XML Attributes at proper location of my Java created XML Object

This is the XML output I currently get: 123 NjUw And this is the XML output I want to have:
Zensursula
  • 173
  • 4
  • 9
2
votes
1 answer

Only output XML elements that are set when serializing

I have the following XML: Payment by credit card already received Is there a way to not output the elements that aren't set…
Thierry
  • 6,142
  • 13
  • 66
  • 117
2
votes
1 answer

How to exclude a class from the XML serialization assembly

I have a C# project where I have to activate XML serialization assembly generation (GenerateSerializationAssemblies in csproj). The project contains a class that is derived from…
dzs
  • 413
  • 4
  • 9