Questions tagged [xml-serialization]

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

Filter by
Sorted by
Tagged with
-1 votes
0 answers
26 views

Generate XML using C# [closed]

As stated in the title I want to write an XML file using C# scripting. By follow the solution from another question asked on stackoverflow (Link to the post: generate xml files based on my c# classes) ...
Stefan Roelands's user avatar
2 votes
2 answers
59 views

XmlSerializer crashes when encountering xml attribute (namespace)

Im trying to Deserialize a XML im getting from a service. But the XmlSerializer failes when encountering the first attribute. My shortened xml looks like this: <?xml version="1.0" ...
merger's user avatar
  • 728
0 votes
1 answer
26 views

Why does my XML deserialization only recognise the first contained object tag

I have the following classes: public interface IVariable { string Name { get; } dynamic Value { get; set; } } public class Namespace : IVariable, IXmlSerializable, IEnumerable<IVariable>...
RoadieRich's user avatar
  • 6,385
2 votes
1 answer
73 views

How to Serialize/Deserialize an unordered_map member of a derived Class

So I'm building a simulated file-system in C++ to study the language better and maybe some system level programming. Im using Boost::Serialization to save the state of the file system when the user ...
Panagiotis Foliadis's user avatar
0 votes
0 answers
30 views

Collection attributes are not serialized to xml [duplicate]

I have a custom serializable generic collection, defined (a simplified example) like this: [Serializable] public class ArrayOfItems<T> : IEnumerable<T> { [XmlAttribute("Setting&...
ElDog's user avatar
  • 1,240
0 votes
0 answers
17 views

Inlining XML elements

I have the following models: public PersonInfo { [XmlElement("initials")] public string Initials { get; set; } [XmlElement("prefix")] public string Prefix { get; ...
Rick de Water's user avatar
-1 votes
1 answer
55 views

C# how to deserialize XML string which has nested same node [duplicate]

<n-hierarchy> <n name="ABC" n_id="971" /> <n name="XYZ" n_id="972"> <n name="jkl" n_id="973"> ...
VInayK's user avatar
  • 1,529
0 votes
0 answers
63 views

C# XML Serialization: Seralizizing Nullable Value Types (Want to Suppress "null" Values Without Decorators/Attributes/ShouldSerialize)

I'm working with code in C# trying to serialize an object to XML. I cannot add XML attributes or extra properties (e.g. bool ShouldSerializeFoo) to this object. Nor can I add any [Xml*] attributes to ...
Doctor Blue's user avatar
  • 3,789
0 votes
0 answers
30 views

Is there exists some way how to make a updatable and serializable class? c#

I'm currently have a one class Profile which has a Name. But after some time, some changes are required (for example, to replace the Name property with a new class PersonalInfo) in the class after ...
Snail's user avatar
  • 57
0 votes
0 answers
32 views

WCF CreateMessage fails on escaped ASCII characters

I am migrating a WCF client application from DotNet Framework to DotNet (Core) 7. The object I am using serializes using ASCII character 0x07 as a separator, which under DotNet Framework would be ...
Andy W's user avatar
  • 229
0 votes
0 answers
29 views

How to automatically deserialize a file that was serialized using BinaryFormatter?

Problem I have a large file that was serialized using BinaryFormatter that I need to create a class for, so that I can serialize similar files. What I have tried I came across this answer that ...
Tyler's user avatar
  • 113
0 votes
2 answers
57 views

How can I serialize 24 hours time to / from XML using C#?

I know how to serialize a "Date" to / from XML using C#: [XmlElement(DataType ="date")] public DateTime LastInvited { get => _LastInvited; set => _LastInvited = value; } ...
Andrew Truckle's user avatar
0 votes
2 answers
47 views

How to generate with java a xml with CDATA on a specific field

I would like to update an old piece of code, but I can't find the correct way to do it with the new system suggested from the deprecated class XmlSerializer, it was deprecated in Xerces 2.9.0. and it ...
4535992's user avatar
  • 418
0 votes
1 answer
40 views

XMLSerializer serializing DateTime property with timezone

I have an object with DateTime properties. The values do not include the timezone. The Kind property is Local. I then serialize the object as follows: var settings = new XmlWriterSettings() { ...
Ivan Debono's user avatar
0 votes
0 answers
164 views

How to serialize an object as a soap-encoded xml in .NET Core

I want to get soap encoded XML but not sure how. Based on these models, I am able to construct a simple XML: public class GamblerCheckRequestXmlModel { [XmlElement("Kontekst")] ...
So_oP's user avatar
  • 1,211
0 votes
1 answer
169 views

Unclear why this Swagger UI fails with 'FormatterNotFoundException' exception only for this specific property

How to make the example working in Swagger while still having [Produces("application/json", "application/xml")] definition in controller method. In .Net Core 6 API, have set up ...
Beli's user avatar
  • 3
0 votes
2 answers
31 views

IXmlSerializable ignores other properties during deserilization

I have a class implements IXmlSerializable, after ReadXml been called, the deserialization process returns and ignore other properties. The xml file is completed, but when deserial it, only the first ...
Lamp's user avatar
  • 321
0 votes
0 answers
18 views

How can I selectively return full XML properties in one method and partial in another using the same C# class?

I have a problem with serialization c# in .net public class User { public int Id { get; set; } public string Name { get; set; } public string Email { get; set; } } Is possible to control ...
Radamanthys's user avatar
0 votes
2 answers
39 views

How to convert string xml into C# Object reading only inner part of the document [duplicate]

I am working on an application where I need to convert string XML into C# object but I am receiving following error. There is an error in XML document (1, 23) InvalidOperationException: was not ...
Muhammad Kamran's user avatar
1 vote
1 answer
62 views

Deserializing legacy XML class types into new class types

I'm supporting a legacy, internal API that uses two classes that are serialized using XML. Both classes are sub-classes of a common base class: namespace My.Namespace { [ Serializable, ...
FunctionalFolds's user avatar
0 votes
1 answer
120 views

How to create CDATA sections with the xsdata library?

I'm working on creating service that talks with Finn API, that requires XML instead of JSON. Based on *.dtd file and xsdata library I generated classes that allows me to build an request object and ...
Krystian's user avatar
0 votes
0 answers
192 views

C# - Serializing to XML information as to which function to bind a delegate too

I need to be able to save a delegate with the information of which function it is connected to. Something like this: In C#: public class Skill { [XmlAttribute("SkillFunction")] ...
user avatar
0 votes
0 answers
21 views

Include XML declaration while genrating XML File using schama classes - generateDS Python

I am trying to generate a xml file in python using the scham class generated using "generateDS" module, but when the xml file is generated it does not include the xml declaration in it. can ...
ATripathi_Pivotree's user avatar
1 vote
1 answer
78 views

XML Serialization Namespace both Child and Parent Elements

Good day all, I have trouble adding namespaces correctly to my XML. Both the parent and child elements have the own namespaces. When restructure the code I have gotten mixed results. My sample code ...
learning's user avatar
0 votes
0 answers
25 views

convert hexcode to html entity after parsing an xml document

While parsing one of the xml files using XML Serializer in java, the html entites are converting into its corresponding hexcode values(like for mdash output is "hexcode value-#x2014;") and ...
rahul soni's user avatar
0 votes
0 answers
24 views

IXmlSerializable struct throws InvalidProgramException on Deserialize()

I have a pretty simple console application. Ignoring missing checks, the program is as follows: using System.Drawing; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; ...
Doshorte  Dovencio's user avatar
1 vote
1 answer
25 views

DateTimes near a DST changeover do not accurately survive a WriteXML/ReadXML roundtrip. How to preserve them?

I recently had an issue that I traced to the fact that when I serialize/deserialize a DataSet to and from XML using WriteXML/ReadXML at very specific times near a DST changeover, the DateTimes are not ...
user21414783's user avatar
-1 votes
1 answer
104 views

Deserializing XML-file with SOAP-envelope and invalid xsd-address

I want to deserialize this kind of XML-files that have SOAP-envelope and invalid .xsd address in the header that doesn't exist anymore (finvoiceack.xsd). Would like to get the nodes to dataset or into ...
Janizei's user avatar
0 votes
3 answers
178 views

C# Serializing an object into XML that includes a list of objects

I need to serialize an XML to attach for an API PUT request. I am using System.Xml.Serialization. The end result needs to resemble the following: <?xml version="1.0" encoding="UTF-8&...
tbproto's user avatar
1 vote
1 answer
465 views

C# Deserialization of xml file returns "'There is an error in XML document (1, 2).'" error

I'm trying to deserialize an xml response I get from a call. I've used Visual Studios "Paste Special" function to prepare my program for how the file is gonna look, and the only change I've ...
Kiesp's user avatar
  • 76
0 votes
0 answers
31 views

How to have an optional element in XStream (XML -> Java Object)

I am serializing an XML document into a Java Object. There are some elements which I want to be optional. If provided in the XML, then it will end up adding extra functionality. But, if the element ...
harvanchik's user avatar
0 votes
1 answer
206 views

Can I make XmlSerializer in .NET 6+ accept a NULL character?

Consider the following minimal example (fiddle): using System; using System.IO; using System.Xml.Serialization; public class Program { public class C { public string S { get; ...
Heinzi's user avatar
  • 169k
-2 votes
1 answer
385 views

Dynamic XML serializer in C#

Passing the root to the xsd.exe, successfully generates the Classes with the proper structure according to the XSD, we can now assign values to the objects of those classes and populate them, the ...
Ariox66's user avatar
  • 630
1 vote
0 answers
83 views

Is there a way to validate that the xml serialization attributes on my classes and properties conform to an xsd schema?

Is there a built-in (or 3rd party) mechanism/library/analyzer that can be used to validate that the xml serialization attributes on a class/property matches the schema. I know that you can't do full ...
Christopher Haws's user avatar
1 vote
1 answer
27 views

XML Serialisation: what happens when an object reference is added?

I started with the following code: public class ChangeRestartProcessing { [XmlElement("ID")] public long TransportId { get; set; } [XmlElement("FI")] public ...
Dominique's user avatar
  • 16.2k
0 votes
0 answers
30 views

Generating Invoices xml - Items found listed under root node & not contained within a collection node

I am trying to generate an Invoice xml for tax services, which contains one or many InvoiceLine elements. The example xml lists "child" elements in the same level, under the root element, ...
Yiannis Leoussis's user avatar
-1 votes
2 answers
108 views

How to parse XML and serialize it again in a custom way which shows empty elements as expanded tags?

I have the following which can be dynamic const data = '<users> <user> <firstname>test</firstname> <lastname /> <age /> </user> </users>' I ...
user2950720's user avatar
0 votes
0 answers
71 views

C# XML deserialize derived class

I'm trying to deserialize a XML using a derived class in C# .NET Framework 4.8: string xml = "<starttrigger>" + "<case>" + &...
Valentin Weiß's user avatar
0 votes
1 answer
48 views

Save saxon tiny tree to database

Our product currently deals with Documents, uses Saxon to run xquery/xpath expressions on them. For better performance we are looking to shift to using TinyTree instead of DOM. We have a lot of ...
jmashalk's user avatar
0 votes
0 answers
41 views

Xml Serialise class with a property being an interface

I am trying to Serialise the class 'Person', which contains a property where the type is an interface. I a getting an exception - System.NotSupportedException - saying ----> System....
user98's user avatar
  • 17
0 votes
1 answer
106 views

Why does CanDeserialize always return false when deserialization succeeds?

I am attempting to deserialize an xml string into an object, nothing strange about that. Everything was fine until I upgraded my project to .Net5. In the upgrade, I had to add a reference to the ...
Random's user avatar
  • 1,916
0 votes
1 answer
1k views

Deserialize XML into a object

Hey everybody i can't deserialize this xml ,having this XML. string xmlString = "<products> <product><Id>1</Id><Name>My XML product</Name></Product> <...
JuulFan's user avatar
  • 31
0 votes
0 answers
81 views

Multiple XmlElements referencing to the same property in c#

I have following two files and Because both files having the same structure, I would like to keep one class and refer it multiple times. XML File1: <?xml version="1.0" encoding="utf-...
Prashant Desai's user avatar
0 votes
1 answer
268 views

Serialize two lists of objects into an XML file

Trying to create an XML file of the following structure: <Objects> <ArrayOfObject1> <Object1> <Object1> </ArrayOfObject1> <ArrayOfObject2&...
steeb3776's user avatar
1 vote
1 answer
30 views

How do I get C# XmlArray deserialization to replace rather than append to a List?

I have a settings class. The class has a list of connection reconnect times. There is a default set of reconnect times set in the constructor, which can be changed by the user. When these are changed, ...
Pete Magsig's user avatar
1 vote
0 answers
26 views

XmlSerializer - how to make a type to show as an attribute rather than element itself for arrays

I have a problem serializing arrays. The problem I am facing makes it impossible to communicate with SOAP service using Visual Studio generated classes and serialization. Below is a narrowed down code ...
m m's user avatar
  • 111
1 vote
0 answers
284 views

.net core 6 web api, how to serialize classes derived from Dictionary?

I have a class that looks like this: [DataContract(Name = "Item", Namespace = "")] public class Item : Dictionary<string, string> { } I have a controller which returns a ...
Jeremy's user avatar
  • 45.2k
0 votes
0 answers
43 views

C# XmlSerialize on an ObservableCollection of derived types which cannot be known at design time

I have an object model which I need to serialize as XML in order to save the state to a text file. I'm mostly happy with how this is working but I'm stuck trying to serialize an ObservableCollection ...
FunkyDexter's user avatar
1 vote
1 answer
542 views

SoapFormatter in .NET Core 3.1?

How should I migrate the following c# 4.8 framework to .NET Core 3.1 ? Code is: public enum E { V } [Serializable] public class Person { public E my_enum; public bool my_bool; } [...] Person p ...
malat's user avatar
  • 12.1k
0 votes
1 answer
27 views

C# List of items serialize to XML: how to remove wrapping list tag instead off the wrapper tag of the items in the list

I need to serialice an object to XML. I'm stuck on this property, which is a list of objects, where I need the wrapper tag of the list, but not the wrapper tag of the items in the list. My code: ...
D. Brugmans's user avatar

1
2 3 4 5
94