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

Does XmlSerializer support property name changes (version tolerant)

I have public bool Included { get; set; } That I want to change to: public bool IsIncluded { get; set; } I want to have backward compatibility. I'd like to only have IsIncluded defined in code but being able to read old xml where the property…
Eric Ouellet
  • 10,996
  • 11
  • 84
  • 119
6
votes
2 answers

Removing invalid characters from XML before serializing it with XMLSerializer()

I'm trying to store user-input in an XML document on the client-side (javascript), and transmit that to the server for persistence. One user, for example, pasted in text that included an STX character (0x2). The XMLSerializer did not escape the STX…
Seth
  • 2,712
  • 3
  • 25
  • 41
6
votes
1 answer

Web Api XML, How to set Encoding, Version, xmlns:xsi and xsi:schemaLocation

I am using asp.net MVC4 Web Api. I have set: Dim xml = GlobalConfiguration.Configuration.Formatters.XmlFormatter xml.UseXmlSerializer = True I have created a class that specifies the XML I need and this works well. I am almost there but I am not…
Marcel
  • 213
  • 1
  • 4
  • 13
5
votes
1 answer

Deserialization / model binding in MVC4 webapi does not work with arrays

I'm using the new WebApi which is part of MVC4 beta. I have the following class: public class Voucher { public string Id { get; set; } public string TableId { get; set; } public Product[] Products { get; set; } } My controller looks…
Achim
  • 15,415
  • 15
  • 80
  • 144
5
votes
2 answers

XmlSerializer - required elements

I'm using XmlSerializer for WCF service (in the case of my service there are reasons for this). But recently I've encountered the problem: I cannot find a simple way to make a reference type property required, i.e. make it's definition in XSD look…
Maksim Tyutmanov
  • 423
  • 1
  • 5
  • 12
5
votes
1 answer

xmlserializer strips xlink from xlink:html svg image tag

I'm creating a javascript interface to dynamically add xlinked images to a map of a classroom. //declare the xlink namespace in the svg header xmlns:xlink="http://www.w3.org/1999/xlink" ... //the code to append the image var temp =…
pluke
  • 3,832
  • 5
  • 45
  • 68
5
votes
1 answer

How to programatically generate a serialization assembly or cs file like XmlSerializer would when using XmlAttributeOverrides?

I want to generate a serialization assembly or .cs file to serialize my types using XmlAttributeOverrides, and then reference this assembly/.cs file in my project directly rather than use XmlSerializer to perform xml serialization/deserialization.…
Rory
  • 40,559
  • 52
  • 175
  • 261
5
votes
1 answer

Cannot Deserialize a SOAP Message programmatically

I get the following exception when I try to deserialize a soap message. I am doing it this way cause I have the response files I want to reuse in testing. I cannot use a real service or the like as it does not fit the architecture for the testing…
aqwert
  • 10,559
  • 2
  • 41
  • 61
5
votes
2 answers

Alternative for deserializing XML with XmlSerializer

I am programming an UWP app and want to deserialize a list inside a xml to a list of Objects: Blue Red
SimpleNotGood
  • 345
  • 3
  • 14
5
votes
4 answers

C# Xml Serializer deserializes list to count of 0 instead of null

I am confused on how XmlSerializer works behind the scenes. I have a class that deserializes XML into an object. What I am seeing is for the following two elements that are NOT part of the Xml being deserialized. [XmlRootAttribute("MyClass",…
Maxqueue
  • 2,194
  • 2
  • 23
  • 55
5
votes
3 answers

How can I "include" one XML file into another XML file?

I have a XML schema like:
Slauma
  • 175,098
  • 59
  • 401
  • 420
5
votes
1 answer

C# XMLSerializer is deserializing the wrong type into a List

The program below is a contrived example of a problem I found when deserializing XML in C#. I have two separate assemblies which declare a type with the same name, 'Country' in the example below. The types are differentiated by XML namespace. When I…
JMc
  • 971
  • 2
  • 17
  • 26
5
votes
1 answer

MyAssembly.XmlSerializers.dll not generated

I am using WCF Test Client to make a request to a service, however i get the following error: Could not load file or assembly 'aDoc_Client.XmlSerializers' or one of its dependencies. The system cannot find the file specified. Server stack trace: …
BrunoMartinsPro
  • 1,646
  • 1
  • 24
  • 48
5
votes
3 answers
5
votes
1 answer

C# Xml Serialization: can't (de)serialize an object that comes from another assembly

I'm trying to XML serialize/deserialize an object in C#. The catch is that this object is of a type that was not declared in the same assembly as the code that is invoking the serialization. Instead, it comes from an assembly loaded dynamically at…
Master_T
  • 7,232
  • 11
  • 72
  • 144