Questions tagged [xmlserializer]

Serializes and deserializes objects into and from XML documents. The XmlSerializer enables you to control how objects are encoded into XML.

Description in Docs

1432 questions
8
votes
1 answer

C# - XML serialization of derived classes

I'm trying to serialize a List of multiple elements (Suppliers, Customers, Products, etc), all deriving from the same class (MasterElement) public class XMLFile { [XmlArray("MasterFiles")] public List MasterFiles; …
Joao Batista
  • 145
  • 2
  • 7
8
votes
3 answers

attribute not being serialized by XmlSerializer

I'd like to serialize a class to XML, assigning an XML attribute to it. Snippet: [XmlType(TypeName = "classmy")] public class MyClass2 : List { [XmlAttribute(AttributeName = "myattr")] public string Name { get;…
user377486
  • 693
  • 2
  • 10
  • 19
7
votes
3 answers

How to serialize property of type Object with XmlSerializer

I have a property: public object Tag but it can contain finite number of types, unfortunately without base type (except object type). But when I serialize the object with this property, it doesn't get serialized. Is there a way to instruct…
dragonfly
  • 17,407
  • 30
  • 110
  • 219
7
votes
1 answer

XMLSerialize an ObservableCollection

I am having a problem in the xml serialization of observable collection. Here is what I am serializing: public enum Status { Pending, Active, Completed, Cancelled } public abstract class Entity : INotifyPropertyChanged { ... } public class…
John Isaiah Carmona
  • 5,260
  • 10
  • 45
  • 79
7
votes
1 answer

Serializer for xml data while calling http post method (Ktor lib)

As I am newbie in Android, I am building an application in which I need to update layer data on Geo server. For that scenario, I m calling post method along with XML body request. I need to send data in xml format in request body and need to get…
RUBY KUMARI
  • 111
  • 1
  • 10
7
votes
5 answers

Ignoring properties on derived classes when using .NET's XmlSerializer

I have a base class with a virtual property and a derived type that overrides the virtual property. The type can be serialized to XML. What I am trying to do is NOT to persist the List of items property when the object is of the derived type. To…
Ken
  • 71
  • 1
  • 2
7
votes
1 answer

Deserialize XML with multiple types

I'm trying to deserialize XML where some same name tags have different xsi types: Test
OHMR
  • 393
  • 6
  • 16
7
votes
2 answers

XmlSerializer - the first deserialization is very slow

I have a solution with two projects; an asp.net MVC application, and a class library. Let's call them project MVC and project CLS. In the project CLS, there are two different versions (V1 and V2) of an XSD file that I have used to create two…
ataravati
  • 8,891
  • 9
  • 57
  • 89
7
votes
6 answers

Serializable dictionary, how to set key name?

Question: I use a serializable dictionary class, found at http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx , to serialize a dictionary. Which works fine, but I run into an annoying problem. …
Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
7
votes
1 answer

How to convert xml attribute to custom object during deserialization in C# using XmlSerializer

I get InvalidCastException: Value is not a convertible object: System.String to IdTag while attempting to deserialize xml attribute. Here's the sample xml:
7
votes
2 answers

How can I stop XmlSerializer transforming ê to ê in an attribute?

I have the following DOM my link When I serialize it to a file using the Java XmlSerializer it comes out like this:
paul
  • 13,312
  • 23
  • 81
  • 144
7
votes
1 answer

Deserializing a single element in a large XML document: xmlSerializer.Deserialize(xmlReader.ReadSubtree()) fails due to namespace issues

I am attempting to process a large XML document (using a XmlReader) in a single pass, and deserialize only certain elements in it using an XmlSerializer. Below is some code and a tiny mock XML document showing how I have attempted to do…
stakx - no longer contributing
  • 83,039
  • 20
  • 168
  • 268
7
votes
2 answers

XmlSerializer constructor error with class derived from a base class

the following code specifies a type "MyBase64Binary" which is derived from a base class "TestBase" using System; using System.Xml.Serialization; using System.Collections; using System.Xml.Schema; using System.ComponentModel; namespace Test { …
Jan Ryll
  • 73
  • 3
7
votes
3 answers

XmlException while deserializing xml file in UTF-16 encoding format

Using C#'s XmlSerializer. In process of deserializing all xml files in a given folder, I see XmlException "There is an error in XML document (0, 0)". and InnerException is "There is no Unicode byte order mark. Cannot switch to Unicode". All the…
keeda
  • 2,605
  • 5
  • 28
  • 27
7
votes
1 answer

XMlSerialization is not serializing a Datetime

When I serialize an object which has a DateTime in it this is returning empty in the XML string. Please see below for my XSD, serializable class generated from the XSD, and serialization helper class which handles the serialization of the XSD. XSD: …
Somedeveloper
  • 817
  • 2
  • 14
  • 31