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

XmlSerializer is throwing InvalidOperationException when using the generic type constraint where

When I try to run the following code (two separated assemblies) ClassLibrary.cs public interface ITest { } Program.cs using System; public class TestClass { public void Test(T x) where T : ITest { } } static class Program { static…
Martin
  • 10,738
  • 14
  • 59
  • 67
7
votes
2 answers

WCF: provide generic FaultException in IErrorHandler

Some context: We have a custom XSD and generate the WSDL and C# code using WSCF.blue. The client side uses ChannelFactory and shares the interface which includes all the attributes added by WSCF.blue to match what is in the XSD. I'm trying to…
Nelson Rothermel
  • 9,436
  • 8
  • 62
  • 81
7
votes
1 answer

.net XmlSerialize throws "WriteStartDocument cannot be called on writers created with ConformanceLevel.Fragment"

Am trying to serialize a class, writing to an XML file as multiple fragments, i.e, write each object of the class as an individual fragment, without the XML header/root. Below is a sample code: [Serializable] public class Test { public int X {…
sppc42
  • 2,994
  • 2
  • 31
  • 49
7
votes
2 answers

Deserializing XML returns null for collection property

I'm trying to deserialize the following XML: test test
Tom
  • 1,561
  • 4
  • 20
  • 29
7
votes
3 answers

Xml deserialization appends to list

I'm trying to deserialize some settings from an xml file. The problematic property/underlying field is one called AlertColors. I initialize the underlying field to white, yellow, and red to make sure that a new instance of this class has a valid…
hattenn
  • 4,371
  • 9
  • 41
  • 80
7
votes
3 answers

C# List<> to xml

Calling List _PCList = new List(); ...add Pc to PCList.. WriteXML>(_PCList, "ss.xml"); Function public static void WriteXML(T o, string filename) { string filePath=…
Taufiq Abdur Rahman
  • 1,348
  • 4
  • 24
  • 44
7
votes
2 answers

Can [XmlText] serialization be nullable?

I have a class containing an array I wish to serialize with XmlSerializer: [XmlArray("properties")] [XmlArrayItem("property", IsNullable = true)] public List Properties { get; set; } Property is a class containing an attribute and some…
ladenedge
  • 13,197
  • 11
  • 60
  • 117
7
votes
2 answers

Deserialize XML string to Object Error : There is an Error in xml document (1,2)

From windows event viewer I can get the following xml structure: XYZ 0
Saher Ahwal
  • 9,015
  • 32
  • 84
  • 152
7
votes
3 answers

Setter not called when deserializing collection

I am trying to do a very simple bit of serialization with XmlSerializer: public struct XmlPerson { [XmlAttribute] public string Id { get; set; } [XmlAttribute] public string Name { get; set; } } public class GroupOfPeople { private…
GazTheDestroyer
  • 20,722
  • 9
  • 70
  • 103
6
votes
2 answers

how to create an xml using xmlserializer in android app

Hi am making a booking app and i need to send an xml to the server after creating the xml. How to create the xml using xmlserializer and send it to a server after creating it? http://api.ean.com/ean-services/rs/hotel/v3/list? minorRev=[current…
vinuonline
  • 143
  • 2
  • 3
  • 14
6
votes
2 answers

How to make a class deserialize as a different name

for instance something like: will serialize just fine to a class called "apple". however, if I want to call that class "Dragon" it will not serialize (which makes sense). I want to know how to mark up "Dragon" such that when the…
LunchMarble
  • 5,079
  • 9
  • 64
  • 94
6
votes
5 answers

error: Could not load the file or assembly 'ExcelAddIn1.XmlSerializers' or one of it's dependencies. The system cannot find the file specified

I have an Add-in project for excel. It works fine on my computer. But when I install it on a client machine it gives me the error message i mentioned. I have Published it using project-> properties-> publish. I have the 'Enable Just my code'…
Fatima
  • 869
  • 10
  • 35
6
votes
1 answer

XmlSerializer and factory-created elements

I am trying to serialize/deserialize objects that have factory-created members. For example, lets say there are a member of type Foo, which is instantiated using FooFactory.CreateFoo(int bar). My current idea is to 1.create a custom XmlReader (for…
Oyvind
  • 568
  • 2
  • 6
  • 22
6
votes
3 answers

How to decorate/define class members for an optional XML element to be used with XmlSerializer?

I have the following XML structure. The theElement element can contain theOptionalList element, or not:
John
  • 15,990
  • 10
  • 70
  • 110
6
votes
3 answers

In JavaScript, how can serializer part of the DOM to XHTML?

I would like to serialize part of the DOM to XHTML (valid XML). Let's assume I have just one element inside , and that this is the element I want to serialize:

With this, document.innerHTML gives…
avernet
  • 30,895
  • 44
  • 126
  • 163