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
9
votes
1 answer
XmlSerializer's functionality in PowerShell?
Is there a way to leverage the functionality of .NET's XmlSerializer class in PowerShell?
More specifically, the ability to easily de/serialize .NET types into Xml e.g.
XmlSerializer s = new XmlSerializer(typeof(MyType));
TextReader r = new…

Ariel
- 5,752
- 5
- 49
- 59
9
votes
3 answers
Serialize a polymorphic List with the same type name
I have an object I'm trying to serialize into XML. Inside this object is a list of a generic type (abstract class). Each item in this list could be a different class, but all are inheriting from the abstract base class:
public abstract class…

JesseF
- 227
- 3
- 10
8
votes
1 answer
System.InvalidOperationException : XmlSerializer attribute System.Xml.Serialization.XmlChoiceIdentifierAttribute is not valid in Item
I have been trying to connect to some web services using WCF but I keep getting an error when I try to call the function I need.
This is the error I'm getting:
System.InvalidOperationException : XmlSerializer attribute…

criel
- 138
- 1
- 6
8
votes
3 answers
XmlSerializer. Skip xml unknown node
I have a problem with deserialization of my xml files. Let's pretend that
we have a xml file and a class that we are using for deserialization to.
For example:
xml -
newDataStore1
sdffasdfasdf
…

Eugene Petrov
- 651
- 1
- 5
- 14
8
votes
1 answer
Serialize object to element with attributes and children
I wish to define classes that will produce the following xml using System.Xml.Serialization.XmlSerializer. I am struggling to get the items list, with attributes that does not contain a child 'container' element for 'item' elements.

Sprintstar
- 7,938
- 5
- 38
- 51
8
votes
1 answer
xml serialization and encoding
i want the xml encoding to be:
To generate encoding like encoding="windows-1252" I wrote this code.
var myns = OS.xmlns;
using (var stringWriter = new StringWriter())
{
var settings = new…

Mou
- 15,673
- 43
- 156
- 275
8
votes
2 answers
Colon character getting encoded to x003A in xml element serialization process
I have defined type as Example as shown below, after instantiating a object and serializing using XmlSerializer, i am getting x003A instead of colon :
Here's my code:
public class Example
{
[XmlElement("Node1")]
…

ANR Upgraded Version
- 857
- 16
- 39
8
votes
2 answers
C# Deserialize XML to object
Having problems deserializing some xml into an object in C#.
The error that I receive is...
xmlns=''> was not expected.
The XSD that I received to generate my class is as follows...

Remotec
- 10,304
- 25
- 105
- 147
8
votes
2 answers
Ignoring specified encoding when deserializing XML
I am trying to read some XML received from an external interface over a socket.
The problem is that the encoding is specified wrong in the XML-header (it says iso-8859-1, but it is utf-16BE). It is documented that the encoding is utf-16BE, but…

Holstebroe
- 4,993
- 4
- 29
- 45
8
votes
2 answers
XmlSerializer: keep unknown elements
I have a class that is serialized into/deserialized from XML and stored in/restored from a file:
public class Customer
{
public string FirstName;
public string LastName;
public Customer()
{
}
public Customer(string…

floppes
- 461
- 3
- 10
8
votes
4 answers
Preserve whitespace-only element content when deserializing XML using XmlSerializer
I have a class InputConfig which contains a List:
public class InputConfig
{
// The rest of the class omitted
private List includeExcludeRules;
public List IncludeExcludeRules
…

CDTWF
- 83
- 1
- 6
8
votes
4 answers
OutOfMemoryError calling XmlSerializer.Deserialize() - not related to XML size!
This is a really crazy bug. The following is throwing an OutOfMemoryException, for XML snippits that are very short and simple (e.g., ):
public static T DeserializeXmlNode(XmlNode node)
{
try
{
return (T)new…

Mike Atlas
- 8,193
- 4
- 46
- 62
8
votes
2 answers
.NET OutOfMemoryException on XMLSerializer.Serialize
I have a web site that is throwing OutOfMemoryExceptions on whenever it gets to the following spot in my code:
XmlSerializer xs = new XmlSerializer(t, xoverrides);
Seeing how this only happens when it is on the web server, i don't have a ton of…

Micah
- 10,295
- 13
- 66
- 95
8
votes
5 answers
Why is XmlSerializer so hard to use?
I imagine to use XML serialization like this:
class Foo {
public Foo (string name) {
Name1 = name;
Name2 = name;
}
[XmlInclude]
public string Name1 { get; private set; }
[XmlInclude]
private string…

mafu
- 31,798
- 42
- 154
- 247
8
votes
3 answers
How do I differentiate types of XML files before deserializing?
I am loading MusicXML-files into my program. The problem: There are two “dialects”, timewise and partwise, which have different root-nodes (and a different structure):

Jannik Arndt
- 447
- 5
- 13