xml-deserialization

How to XML serialize and deserialize an instance of Dictionary <type, List<Action<T>>>?

情到浓时终转凉″ 提交于 2019-12-25 06:55:26
问题 I want to serialize and deserialize my dictionary object of type Dictionary <type, List<Action<T>>> . I tried using XMLserializer - it fails. Cannot serialize member MyClass.MyDictionary of type System.Collections.Generic.Dictionary‘2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], because it implements IDictionary. I am using .NET framework 4.0. What is

Serializing / Deserializing the derived class

时间秒杀一切 提交于 2019-12-24 23:24:37
问题 I have a base class and another derived from it. Let's assume, the base class has 20 members and derived has 5 members. Only the derived class is serializable. After I instantiate, the derived class's object has all 25 members. Now how can I only serialize the 5 members of derived class? When I use "this" to serizalize or deserialize, the entire class (all 25 members) is serialized and then deserialized. Here is a code snippet (not complete): // Base class definition. public abstract class

Error <Report xmlns='NonEmpty'> was not expected

不想你离开。 提交于 2019-12-24 22:27:26
问题 Following the steps from Lesson 3: Load a Report Definition from the Report Server for SQL Server 2012, I have the following error: System.InvalidOperationException was unhandled HResult=-2146233079 Message=There is an error in XML document (2, 2) . . InnerException: System.InvalidOperationException HResult=-2146233079 Message=<Report xmlns='http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition'> was not expected. When I reached the last line: _report = (Report)serializer

Error in deserializing the XML data in C#

早过忘川 提交于 2019-12-24 22:08:04
问题 I have a SVG file in XML format i am trying to deserialize XML to C# objects but when trying to deserialize XML data it is giving error Below is my code XmlSerializer serializer = new XmlSerializer(typeof(List<rootobject>)); object objectList = null; using (StreamReader stream = new StreamReader(@"C:\Users\sana-user\Documents\Visual Studio 2015\Projects\SVGXMLToJsonApp\SVGXMLToJsonApp\File\3rect.svg")) { objectList = serializer.Deserialize(stream); } Console.WriteLine(objectList); Below is my

How to Deserialize XML in c# having child nodes of same type

不想你离开。 提交于 2019-12-24 19:56:27
问题 I need to deserialize bellow XML. The chapter element can have multiple child chapter element in it.I have tried to deserialize the XML using XmlSerializer. All the elements are deserializing as expected but the issue is that the child Chapter array is not deserializing, am I missing something here? Please help. <Survey> <SurveyResults> <Subject> <Chapter> <ChapterIterationName /> <Questions /> <Chapter> <ChapterName>CHAPTER 1</ChapterName> <ChapterIterationName /> <Questions> <Question>

Deserialization Xml Document Error

↘锁芯ラ 提交于 2019-12-24 19:30:00
问题 I have a problem when I deserialize the xml into List of Objects. I searched it on the net this morning, but my problem isn't resolved. Deserialization method public static List<FileAction> DeSerialization() { XmlRootAttribute xRoot=new XmlRootAttribute(); xRoot.ElementName="ArrayOfSerializeClass"; xRoot.IsNullable=true; XmlSerializer serializer = new XmlSerializer(typeof(List<FileAction>),xRoot);//, new XmlRootAttribute("ArrayOfSerializeClass") using (Stream streamReader = File.OpenRead(@"C:

put xml into Array

那年仲夏 提交于 2019-12-24 17:09:33
问题 I have an xml file, and I need to be able to sort it in either a list or an array The XML: <Restaurant> <name>test</name> <location>test</location> </Restaurant> <Restaurant> <name>test2</name> <location>test2</location> </Restaurant> All the Restaurants will have the same number of fields and the same names for the fields, but the number of <Restaurant></Restaurant> in a given xml file is unknown. In other words, I need an array or list and be able to do this: String name = restaurantArray[0

C# can't deserialize XML containing xsi:type

China☆狼群 提交于 2019-12-24 08:12:23
问题 I am trying to deserialize the following XML <?xml version="1.0" encoding="UTF-8"?> <GovTalkMessage xmlns="http://www.govtalk.gov.uk/CM/envelope"> <EnvelopeVersion>2.0</EnvelopeVersion> <Header> <MessageDetails> <Class>DRUG_DATA</Class> <Qualifier>response</Qualifier> <Function>submit</Function> <CorrelationID>BD694DAAA26AA6068EAAAE5C7746CE54</CorrelationID> <Transformation>XML</Transformation> </MessageDetails> <SenderDetails> <IDAuthentication> <SenderID /> <Authentication> <Method /> <Role

XStream deserialization when variable type changed

时光总嘲笑我的痴心妄想 提交于 2019-12-24 06:48:00
问题 I have a java class that looks like public class MyClass { private final String str; private Polygon polygon; // this polygon is a custom type of mine } I have an xml file that has an instance of MyClass written to it using XStream. Now MyClass has changed and polygon has been replaced with List<Polygon> and the field has been renamed to polygons , and I'm trying not to break deserialization. I want to change the deserialization of the polygon field to basically read the polygon and then just

C# XML Deserialization W/ Default Values

流过昼夜 提交于 2019-12-24 03:50:30
问题 I've got an object that is being serialized / deserialized via the XmlSerializer in C#, .NET 3.5. One of the properties (and more in the future) is a collection: List where T is an enum value. This serializes / deserializes fine. We are also using a "default values" mechanism to provide default values for the object, in case the serialized version doesn't have any value set. as a simple example, here is what we are dong: public enum MyEnum { Value1, Value2 } public class Foo { public List