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
23
votes
6 answers
How to XML-serialize a dictionary
I have been able to serialize an IEnumerable this way:
[XmlArray("TRANSACTIONS")]
[XmlArrayItem("TRANSACTION", typeof(Record))]
public IEnumerable Records
{
get
{
foreach(Record br in _budget)
{
…

Burnzy
- 233
- 1
- 2
- 4
23
votes
2 answers
How to generate tag prefixes using XmlSerializer
I wanted to generate the following using XmlSerializer :
So I tried to add a Namespace to my element :
[...]
[XmlElement("link", Namespace="atom")]
…

hoang
- 1,887
- 1
- 24
- 34
22
votes
4 answers
XmlSerializer startup HUGE performance loss on 64bit systems
I am experiencing a really HUGE performance loss while calling a simple XmlSerializer.Deserizlize() on a class with lots of fields.
NOTE: I'm writing the code without Visual Studio, at home, so it may have some errors.
My serializable class is flat…

Filini
- 2,109
- 2
- 22
- 32
22
votes
2 answers
How do I add a default namespace with no prefix using XMLSerializer
I am trying to generate an XML document that contains the default namespace without a prefix using XmlSerializer, e.g.
-
…

OldBob
- 221
- 1
- 2
- 4
20
votes
4 answers
axis2 maven example
I try to use axis2 (1.5.1) version to generate java codes from wsdl files, but I can't figure out what is the correct pom.xml
org.apache.axis2
…

Larry Cai
- 55,923
- 34
- 110
- 156
19
votes
4 answers
remove encoding from xmlserializer
I am using the following code to create an xml document -
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");
new XmlSerializer(typeof(docket)).Serialize(Console.Out, i, ns);
this works great in creating the xml file with…

czuroski
- 4,316
- 9
- 50
- 86
19
votes
1 answer
XmlSerializer.Deserialize on a List<> item
I've tried all the solutions I could find on SO and elsewhere, but can't seem to figure out why this is not working.
Straightforward deserialization of an XML string into an object, the object has one property - a…

staterium
- 1,980
- 2
- 20
- 32
18
votes
2 answers
Controlling order of serialization in C#
I'm using an XmlSerializer to serialize an object and write it to a file. I've had quite a bit of success with the serializer doing what I want it to do in terms of nesting elements and what is serialized as elements vs attributes. Unfortunately,…

Zann Anderson
- 4,767
- 9
- 35
- 56
18
votes
5 answers
Using generics with XmlSerializer
When using XML serialization in C#, I use code like this:
public MyObject LoadData()
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(MyObject));
using (TextReader reader = new StreamReader(settingsFileName))
{
return…

Arseni Mourzenko
- 50,338
- 35
- 112
- 199
15
votes
1 answer
Deserialize random/unknown types with XmlSerializer
I am using XmlSerializer to communicate with a service. This is not a regular SOAP service, it has its own XML object types. For example, I may ask for a object, but it may return an . So, in other words, I have to deal…

Oyvind
- 568
- 2
- 6
- 22
15
votes
2 answers
How to cause XmlSerializer to generate attributes instead of elements by default
Is there a way to cause XmlSerializer to serialize primitive class members (e.g. string properties) as XML attributes, not as XML elements, without having to write [XmlAttribute] in front of each property declaration?
I.e. is there a global switch…
user128300
14
votes
5 answers
WCF Error "Maximum number of items that can be serialized or deserialized in an object graph is '65536'"
I am receiving the following error on a WCF call:
Maximum number of items that can be serialized or deserialized in an
object graph is '65536'
I've read a ton of forum posts and many of them mention modifying the app.config and web.config to…

Scot
- 572
- 1
- 7
- 27
14
votes
1 answer
Is XmlRootAttribute inheritable?
I have a class I am serializing with C#'s XmlSerializer. It is marked with the XmlRoot attribute, and I would like to inherit this attribute in a derived class.
Looking at the documentation it does not say that XmlRoot sets Inherit to false with…

sourcenouveau
- 29,356
- 35
- 146
- 243
14
votes
1 answer
XML (de)serialization invalid string inconsistent in c#?
In C# (.net 4.0 and 4.5 / vs2010 and vs12) when I serialize an object containing a string having an illegal character using XMLSerializer, no error is thrown. However, when I deserialize that result, an "invalid character" error is thrown.
…

Robbie
- 715
- 3
- 10
- 18
14
votes
1 answer
Why do I get ActionNotSupportedException for my WCF client/service?
I'm learning WCF, specifically I'm learning how to write them contract first, ala wscf.blue
I can create a WCF client/service the contract last way (Microsoft)
I can create a WCF client/service the contract first way (WSCF)
But, if I create a…

RoboJ1M
- 1,590
- 2
- 27
- 34