xml-serialization

Best method for serializing objects in .NET (as of v4.0)

I have an simple custom object called MyObject (a couple of basic properties and a List(of MyObject), so it's recursive) that I need to serialize for storage. I'm not sure if I'll serialize to XML or Binary yet, but I want to make sure I'm using the most up-to-date methods for doing it, as there are a few different namespaces involved an...

Force Loading of all Related Entities within Entity without knowing Entity Class Types

I'm trying to serialize an entity and all its related entities for storing as xml before physically deleting the entity (leaving an audit trail). I'm using a DataContractSerializer which seems to be getting around the shallow serialization performed when using an XmlSerializer. The only trouble is that only related entities that have b...

IDeserializationCallback in XMLSrializer...

Is there a way to utilize the IDeserializationCallback interface with the standard xmlSerializer? It does not appear to be supported in this context. IDeserializationCallback works fine when used with the binary formatters. Basicaly i want to do some calculation when de-serialization e.g.: public void IDeserializationCallback.OnDeser...

.Net Xml Deserialization - Support Multiple Namespaces

Hello, I need to support XML deserialization of two very similar, yet different xml files. File 1: <?xml version="1.0" encoding="UTF-8"?> <lr:LogReport xmlns:dcml="http://www.x1.org/schemas/Types/" xmlns:ds="http://www.x3.org/2000/09/xmldsig#" xmlns:lr="http://www.x.org/schemas/LogRecord/" xmlns:xs="http://www.x3.org/2001/...

XmlInclude to (De)Serialize Inherited Types in Separate Assemblies

hey all, I have this scenario: namespace MyApp.Animals { public class Dog : MyApp.Categories.Canine ... So I'm trying to serialize/ deserialize the dog class. Unfortunately I can't use the [XmlInclude] attribute, because by adding it to the parent class (MyApp.Categories.Canine), I need to add a reference to the assembly in whic...

Help needed in XML Serialization.

I am trying a write a program to serialize a object to a xml file. [XmlRoot ("Person")] public class person { [XmlElement("Name")] public string name { get; set; } [XmlElement("Age")] public int age { get; set; } [XmlElement ("Location")] location _location = new location { city...

Generating XML dynamically from the data entered on UI.

Hi All, I have a xml file which is currently made manually and I have to make a functionality(UI) where user can enter the data and I have to store the data and generate the xml file dynamically in .NET. Problem is the format of the xml file. I am not able to decide how I am going to store that data and then dynamically generate xml fr...

De-serializing a list from an XML file to a DataGridView.

I have a class (below is an example) that contains a list of objects. This class also contains other members. I deserialize this class upon loading my program and serialize it upon closing. I want to keep everything regarding the configuration of the UI in one XML file. The issue is I want to give the user a way of editing the ButtonLis...

How to rename <ArrayOf> XML attribute that generated after serializing List of objects

I am serializing List of objects List<TestObject> , and XmlSerializer generates <ArrayOfTestObject> attribute, I want rename it or remove it. Can it be done with creating new class that encapsulated List as field? [XmlRoot("Container")] public class TestObject { public TestObject() { } public...

Would it make sense to use XAML for configuration scenarios?

One simple way to add some configuration is to define a configuration section which is not much more than some object that can be (de)serialized based on the XmlSerializer classes. Now, XAML is at its heart more or less a hierarchy of objects but provides things like naming of elements, binding, etc. Has anyone ever used XAML outside i...

XML namespace for attributes

Question: I have an xml element + attributes, which all need to be in a namespace. I set the element + all attributes into the namespace oai, and I get: <oai:room building="AB" rmName="001"> but the XML i need to generate should look like this: <oai:room oai:building="AB" oai:rmName="001"> Why does it remove the oai namespace in t...

Can I create an application or object from an existing XML file

Hi, I have a couple of XML files that are used to control unattended installations of sharepoint. I need to create a simple desktop application that will create / modify these xml files. Before i go through and create a load of stuff manually is there any way i can automate some of the process. I.E. can i generate my objects from an XM...

Upgrading XML Schema programmatically

Hi all. I'm in the process of having to re-write a project due to the platform vendor needing the storage mechanism be in an XElement object instead of storing in data tables that I create in their database. It's becoming painful, and I need some insight. I can morph my object graph to/from Xml using the XmlSerializer and read/write t...

Defining XmlRoot and typeof it with a variable?

[XmlRoot("ConfigurationRoot")] public class XmlDBConfiguration { [XmlArray("Customers")] [XmlArrayItem("Customer", typeof(Customer))] public ArrayList _customers; private Dictionary<string, Customer> _customerDictionary;} Is it possible to define the Element Name (in my case it is ConfigurationRoot) with a variable fro...

How can i deserialise two xml files with different tags but the same data

Hi, I have two xml files with the same data but different tags. I need to serialise them into an object. At first i tried to create the classes: [XmlRoot(ElementName="ONIXMessage")] public class ONIXMessage { [XmlAttribute(AttributeName="release")] public string Release { get; set; } [XmlElement("Header")] public Hea...

Need help loading XML data into XNA 4.0 project

I'd like to do this the right way if possible. I have XML data as follows: <?xml version="1.0" encoding="utf-8"?> <XnaContent> <Asset Type="PG2.Dictionary"> <Letters TotalInstances="460100"> <Letter Count="34481">&#97;</Letter> ... <Letter Count="1361">&#122;</Lette...

Alternative to XML Serialization for Configuration

Currently, we use a giant configuration object that is serialized to/from XML. This has worked fine for the most part, but we are finding that in the case of power loss and application crashes, that the file could be left in a state that renders it unable to deserialize properly, effectively corrupting the configuration information. I w...

Using Boost.Serialization to parse a custom XML format

Hello, I have a custom XML format that needs to be serialized to objects. I only need to serialize certain tags and ignore the rest. I have the impression that I need to write my own archive class but there is no documentation that explains how can it be done. I do not need to save anything, just load the initial state of the object. Any...

Using IXmlSerializable interface on complex object graph

If using custom XML Serialization (IXmlSerialiable), on a complex object that contains properties with constituent complex objects which do NOT use custom IXmlSerializable interface, how do you specify, in the IXmlSerializable.ReadXml(XmlReader reader) method, that you want the deserializer to use the ordinary deserialization on those ch...

CS1567 XmlSerialization error temp file collision between processes?

My question is about the temporary files that are generated by the .NET framework in support of XmlSerialization. Here is the background prompting me to ask the question. The software that I have deployed is deployed in 4 environments all of them windows 2003 servers. The .net runtimes on all 4 environments are the same service packs....