Questions tagged [xml-serialization]

This tag refers to serialization technologies which use XML as a data format.

This tag refers to serialization technologies which use XML as a data format. In the context of .NET, it refers to the XmlSerializer class, less so to the DataContractSerializer class, still less to the SoapFormatter class.

4687 questions
2
votes
2 answers

Cannot Build Simple Boost XML Serialization Example

I'm trying to work with the Boost Serialization libraries for some experimenting on upcoming projects I know that the Boost Serialization library must be compiled separately from the rest of the projects/headers. I've installed a package for this on…
pseudoramble
  • 2,541
  • 22
  • 28
2
votes
1 answer

Declaratively define xml serialization using pocos

Normally in C# Xml types are marked with attributes to define the way how they get serialized: /// [System.Xml.Serialization.XmlTypeAttribute(Namespace= "urn:xmlns:25hoursaday-com:my-bookshelf")] public class bookType { ///…
schoetbi
  • 12,009
  • 10
  • 54
  • 72
2
votes
1 answer

XmlSerializer and IEnumerable: Serialization possible w/o parameterless constructor: Bug?

In our project we extensivly use the XmlSerializer. By chance I found a class w/o a parameterless contructor. I thought this must break the serialization process but it did not. By investigating this issue I found out, that the XmlSerializer behaves…
mklein
  • 1,787
  • 1
  • 15
  • 18
2
votes
2 answers

XmlSerializer and InternalsVisibleTo attribute

Is it possible to make XmlSerializer serialize internal class members by using InternalsVisibleTo attribute? If it is, what assembly should I make my internals visible to. In other words, what assembly name and public key should I provide to the…
e11s
  • 4,123
  • 3
  • 29
  • 28
2
votes
2 answers

How can I use DataContractSerializer to deserialize from a single node of an XMLDocument?

The readers that DataContractSerializer uses in ReadObject seem to be stream-based. I already have an XMLDocument, and I would like to deserialize one part of that document. In this code snippet, I am deserializing a MyItem object from a…
pc1oad1etter
  • 8,549
  • 10
  • 49
  • 64
2
votes
4 answers

How to deserialize XML result from a HTTP POST request in Java?

In C#, I make an http post and get an xml in the response in the form of a byte array (bret), which I deserialize into a class easily: MemoryStream m = new MemoryStream(bret); XmlSerializer s = new…
juan
  • 80,295
  • 52
  • 162
  • 195
2
votes
1 answer

Serialize two nodes with the same name but different child nodes

I need to be able to define two nodes with the same name but completely different subnode structures. I didn't design this XML schema but for the time being I'm forced to use it as is. I realize it's a terrible abuse of everything that is XML but…
Thomas Paine
  • 301
  • 3
  • 11
2
votes
1 answer

Decimal point removed from decimals in a Serialized XML

I'm using XmlSerializer with classes created from a xsd using xsd.exe. It has worked fine for months. Now I'm receiving reports that in some cases the created xml file has all decimals serialized without a decimal point, e.g. 123.45 is serialized…
MiguelM
  • 197
  • 2
  • 9
2
votes
2 answers

How to serialize an array of a base class filled with its subclasses to XML?

I'm trying to serialize an array of Test objects that contains some TestChild objects. public class Test { public string SomeProperty { get; set; } } public class TestChild : Test { public string SomeOtherProperty { get; set; } } class…
neo2862
  • 1,496
  • 1
  • 13
  • 27
2
votes
2 answers

XmlSerializer enumeration deserialization failing on (non existent) whitespace

I have an object I'm deserializing which contains an enum 'JourneyPatternLinkDirectionEnumeration', it's used as a value for a node 'Direction'. When 'Direction' is specified with a value, or not specified and it's represented in xml as
Doobi
  • 4,844
  • 1
  • 22
  • 17
2
votes
1 answer

Deserializing elements with both attributes and value

Given an XML structure that countains both attributes and element values, how do I construct my C# classes using the System.Xml.Serialization attributes? My XML looks like this: 100987654321
2
votes
1 answer

Serialize class with array property including index of array elements

I have a class public class clsTest { public string name; [XmlArray(ElementName = "values")] [XmlArrayItem(ElementName = "value")] public float[] values; public clsTest() { name = "name-test"; values = new…
2
votes
4 answers

Remove p2:type="<>" xmlns:p2="http://www.w3.org/2001/XMLSchema-instance" from xml

How to remove xmlns from all the inner nodes of the xml. I was able to remove the xmlns from the root node but still the inner node has all the xmlns in the inner node. public class Program { public static void Main() { List
Gopi
  • 5,656
  • 22
  • 80
  • 146
2
votes
2 answers

.Net Core Serialize an Object with IEnumerables to Save as XML

I am using .net Core 1.1 and writing a console application. I need to Serialize an Object with some basic properties of strings and int as well as some IEnumerable Objects and serialize it as XML so I can save it to a "data.xml" file. I receive the…
Scornwell
  • 597
  • 4
  • 19
2
votes
1 answer

XML serialization and inheritance

class A : IXmlSerializable { ... } class B : A { public string X; } When i serialize object of type B, only A is serialized. How can I include X with minimum effort?
watbywbarif
  • 6,487
  • 8
  • 50
  • 64