xml-serialization

How can I make the xmlserializer only serialize plain xml?

I need to get plain xml, without the <?xml version="1.0" encoding="utf-16"?> at the beginning and xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" in first element from XmlSerializer. How can I do it? ...

UTF8 Beginning of File characters are breaking serializer & readers

Okay, I'm trying to work with UTF8 text files. I'm constantly fighting the BOF chars that the writer drops in for UTF8, which blows up pretty much anything I need to use to read the file including serializers and other text readers. I'm getting a leading six bytes of data: 0xEF 0xBB 0xBF 0xEF 0xBB 0xBF (now that I'm looking at it...

XML Serializer: why deserialization doesn't work in my case?

Hi, guys. I use XMLSerializer to keep and restore program options. Here is the code: using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Xml; using System.Windows.Forms; using System.Xml.Serialization; namespace XMLAsk { class Test { public static string ConfigFileName = "C:\...

Settable collection properties:

Framework Design Guidelines gives this advice: DO NOT provide settable collection properties. But if I don't, I can't see a way to XML serialize anything with a collection property. The XmlSerializer constructor complains, "Unable to generate a temporary class (result=1). error CS0200: Property or indexer 'ConsoleApplication1...

customising serialisation of java collections using xstream

I have an object that needs to be serialised as XML, which contains the following field: List<String> tags = new List<String>(); XStream serialises it just fine (after some aliases) like this: <tags> <string>tagOne</string> <string>tagTwo</string> <string>tagThree</string> <string>tagFour</string> </tags> That's OK as far a...

Is there an easier way to deserialize similar XML files?

I am writing a class library which abstracts data contained in XML files on a web site. Each XML file uses the same root element: page. The descendant(s) of page depend on the specific file that I am downloading. For example: <!-- http://.../groups.xml --> <page url="/groups.xml"> <groups> <group id="1" > <members> <...

Create virtual methods using xsd.exe

I am using classes that were generated from an XML schema using the xsd.exe tool. It currently generates a huge (32k line) .cs file. I then serialize and deserialize parts of the of model using XMLSerializer. I need to override properties in these classes, so I have partial classes in separate files that override some of these generated...

XmlSerializer doesn't serialize everything in my class

I have a very basic class that is a list of sub-classes, plus some summary data. [Serializable] public class ProductCollection : List<Product> { public bool flag { get; set; } public double A { get; set; } public double B { get; set; } public double C { get; set; } } ... // method to save this class private void Save...

Serializable class inheriting from an Interface with a property of its own type

I have an interface, with a definintion for a property that is the same type as the interface. public interface IMyInterface { IMyInterface parent { get; set; } } Now if I declare a class and inherit from the interface, I need to create the property called parent. I want my class to be serializable to us...

How can i generate xml from an object hierarchy?

I have object, tree/model/hierarchy, whatever the correct term is. It consists of what could be characterized as a one-to-one mapping of the desired XML. That is i have the following (in a non-standard UML sort of syntax) class A { class B b[*] class C class D } class B { class C c[*] string AttributeFoo = "bar" } ...

XML alternative of Text.JSON.Generic for Haskell

Is there any XML-(de)serializer for Haskell using Data/Typeable with functions similar to toXml :: Data d => d -> XmlValue fromXml :: Data d => String -> Result d in the spirit of Text.JSON.Generic? ...

XML file reading error

Hello, help me please i'm having the following issue: I'm trying to read a XML file that looks like this: <service /> <parameters> <parametro nombreParametro="payment" valorParametro="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;" tipoParametro="string" /> </parameters> The xml file is well formed, but as you c...

Quick and dirty reflection based XML Serializer

Does anyone know of a quick and dirty implementation of a reflection based XML serializer? I am looking to rip out my XML serialization code due to the horrid start up time. I know about sgen.exe but do not want to complicate my build and packaging process. We use the XML serialization at startup to pull out configuration values from...

How to serialize and save an object to database as Xml using Linq to SQL

I were using FileStream to Serialize an Object to Xml and Save to the disk Stream str = new FileStream(@"serializedstate.xml", FileMode.OpenOrCreate) XmlSerializer x = new XmlSerializer(typeof(GridState)); x.Serialize(str, new GridState { GridName= txtGridName.Text, GridColumns = GetGridColumnStates() ...

XML Deserialization of carriage returns causes unprintable characters

Situation: When I deserialize XML that contains carriage returns, the characters appear as unprintable character "boxes" rather than as carriage returns. Background: User input collected via a multi-line textbox contains carriage returns within the text. I am persisting this text data to XML using the .NET XML serializer (snippet below...

Incomplete XML attribute

I am creating XML out of Dataset by dataset.GetXML() method. I want to add attributes to it XmlAttribute attr = xmlObj.CreateAttribute("xmlns:xsi"); attr.Value = "http://www.createattribute.com"; xmlObj.DocumentElement.Attributes.Append(attr); attr = xmlObj.CreateAttribute("xsi:schemaL...

Pre-generating XmlSerializers using Sgen and ILMerge. Trouble with arrays.

I use XmlSerializer extensively and rather than allowing .NET to generate the necessary serialization assemblies at runtime, I'd like to generate these assemblies ahead of time and bundle them with my application. I am able to use Sgen to generate these assemblies at build time. Additionally, I must run Sgen separately for each array typ...

Rehosting workflow designer

I'm creating an application that rehost the workflow designer and that can load an xoml only workflow. When I deserialize my xoml-only workflow. There is an error stating : {"Could not deserialize object. The type 'MyCustomActivity' could not be resolved."} my xoml looks like this: <SequentialWorkflowActivity x:Name="Workflow2" xmlns:...

Render Empty XML Elements as Parent Elements

I have a strange requirement where an application consuming some XML that my application is generating actually needs empty elements to be serialized as parent elements. For example: <element foo="bar" /> should be: <element foo="bar"></element> I'm not aware of any way that the XmlSerializer allows you to change this. Does anybody kn...

.NET WebService Sending Large XML File

I have a list of objects List that I need to send over a web service. The list contains about 37,000 Objects. This translates to about a 125 MB XML File if I serialized it to XML. I think by default web services communicate via serialized XML. This leads me to believe I am actually sending 125MB file each time. In binary format this...