Serializes and deserializes objects into and from XML documents. The XmlSerializer enables you to control how objects are encoded into XML.
Questions tagged [xmlserializer]
1432 questions
5
votes
1 answer
.NET XmlSerializer and multidimensional arrays
I'm implementing a program which acts as a client to some existing software. The protocol is defined using an XML schema, and it includes multidimensional arrays.
The .net XmlSerializer cannot handle those - it's a known issue.
Is there a way to…

RasmusW
- 3,355
- 3
- 28
- 46
5
votes
1 answer
FileMode.Open and FileMode.OpenOrCreate difference when file exists? c# bug?
I have wrote that code:
public void Save()
{
using (FileStream fs = new FileStream(Properties.Settings.Default.settings_file_path, FileMode.Open))
{
XmlSerializer ser = new XmlSerializer(typeof(MySettings));
ser.Serialize(fs,…

Robert Rudnicki
- 53
- 1
- 5
5
votes
2 answers
Serialize an object that contains a list of objects
I'v build a NotInheritable Serilizer that serilizes all my classes and list of classes with success.
Until I'v build a list of class that contains a list of classes.
I'm getting the runtime Exeption: There was an error generating the XML document.…

Rob Heijligers
- 193
- 1
- 2
- 9
5
votes
2 answers
XML Serialisation - When To Use DataContractSerializer / Binary / XMLSerialiser
I ve been looking at this for a while now
It seems that binary serialisation is discouraged as any change to field names breaks serialisation =? Not Good
XMLSerializer is problematic because you have to provide a no arg constructor and public…

Jack Kada
- 24,474
- 29
- 82
- 106
5
votes
2 answers
Ampersand in XML url is not passed through
I'm having hard-time fixing this little problem of ampersand (&) in the url... I'm serializing XML as shown below...
var ser = new XmlSerializer(typeof(response));
using (var reader = XmlReader.Create(url))
{
response…

Nick Kahn
- 19,652
- 91
- 275
- 406
5
votes
2 answers
Pass list of known types to object with its own XmlSerializer in (de-)serialization tree
I use C# 3 on microsoft .net 3.5 (VS2008).
I have a problem with de-serialization. I use DataContract and DataMember in a hierarchy of classes that I want to be serializable.
However, I also have polymorphism in one container, so I need to pass a…

v.oddou
- 6,476
- 3
- 32
- 63
5
votes
2 answers
deserialize with different root element names
The following example gives me "[One xmlns=''] was not expected." exception
public abstract class BaseClass{ }
[XmlRoot("One")]
public class ChildOne : BaseClass {}
[XmlRoot("Two")]
public class ChildTwo : BaseClass { }
class Program
{
…

m_kramar
- 410
- 4
- 15
5
votes
1 answer
Prefix SOAP XML Instead direct namespace
I am working with one of our partner to integrate our business services. I am using WCF (.Net 3.5) to communicate with partner web service. I think partner web service is written in Java.
Using SVC util I generated proxy class. Instead DataContract…

Amzath
- 3,159
- 10
- 31
- 43
5
votes
0 answers
How do I stop d4p1 being a required namespace prefix within my WCF service SOAP request XML
I've built my first ever WCF service designed to receive HTTP Post requests that have a message body in a strict format that I have no influence over. Here is an example:
…

user2295803
- 51
- 3
5
votes
1 answer
extra closing bracket in xml
I am using this example to save some variables to an xml file:
how do I set the current class to the return types results
This is my code for the settings file:
using System;
using System.IO;
using System.Xml.Serialization;
namespace…

ErocM
- 4,505
- 24
- 94
- 161
5
votes
4 answers
Force XMLSerializer not to collapse empty tags?
Is it possible via any configuration option to tell JavaScript's XMLSerializer not to collapse empty tags into self-closing tags? I'm feeding an xml string into the xml parser then reserializing it after making modifications to the tree, but where I…

devios1
- 36,899
- 45
- 162
- 260
5
votes
3 answers
XmlSerializer - How can I set a default when deserializing an enum?
I have a class that looks like this (heavily simplified):
public class Foo
{
public enum Value
{
ValueOne,
ValueTwo
}
[XmlAttribute]
public Value Bar { get; set; }
}
I'm receiving an XML file from an external…

NeilD
- 2,278
- 3
- 24
- 28
5
votes
1 answer
Custom XML output?
Playing around with the Web API with Framework 4.0
Wanted XML only output, so removed the JSON formatter from the formatters collection.
Now, I'd like to modify the standard XML that the XMLSerializer is outputting:

user1771591
- 87
- 2
- 9
5
votes
3 answers
Deserializing xml to class, trouble with list<>
I have the following XML
I am trying to…

Toodleey
- 913
- 1
- 8
- 22
5
votes
2 answers
Unable to generate a temporary class - Cryptographic failure while signing assembly
I have a signed class library that I want to create assemblies for via the sgen tool. However, I get an error when I try to run the following command:
$ sgen.exe /a:testsign.dll /force /compiler:/keyfile:..\..\testsign.pfx /verbose /n
Error:…

default
- 11,485
- 9
- 66
- 102