xml-serialization

XML serialize annotations

拟墨画扇 提交于 2020-01-04 07:25:07
问题 I have a situation where I have an xml file that I don't want to modify. The AddAnnotation function in XElement class provides an option to add memory-only data which is not serialized and not part of the XML. I want to be able to save these annotations (for example: to another xml file) and then to deserialize both the xml and the annotations in order to get the same object I had. I don't want to change the original xml and that's the reason that I use annotations. To summarize, I want to be

Converting Class to XML to string

柔情痞子 提交于 2020-01-04 05:10:11
问题 I'm using XMLSerializer to serialize a class into a XML. There are plenty of examples to this and save the XML into a file. However what I want is to put the XML into a string rather than save it to a file. I'm experimenting with the code below, but it's not working: public static void Main(string[] args) { XmlSerializer ser = new XmlSerializer(typeof(TestClass)); MemoryStream m = new MemoryStream(); ser.Serialize(m, new TestClass()); string xml = new StreamReader(m).ReadToEnd(); Console

Delphi 2010 - Decode Base64 encoded image from XML doc

让人想犯罪 __ 提交于 2020-01-04 04:07:08
问题 I am trying to decode a base64 encoded EMF image from an XML document in my application and render it on screen, however, it never seems to appear. If I copy/paste the data from the XML document into Notepad++ and use the Base64 Decode option and save the file as a .emf it opens fine in mspaint. So I think the issue is how I am decoding it. I have tried the following decode methods described in these articles: How to encode / decode Base 64 string http://www.swissdelphicenter.ch/torry

XmlSerializer.Deserialize() isn't deserializing a List<T> correctly

白昼怎懂夜的黑 提交于 2020-01-03 12:34:36
问题 I am new to the C# XmlSerializer so I might be missing something basic here. The problem I am running into is that I have one class that has a List<T> of another class. When I serialize the main class the XML looks beautiful and all the data is intact. When I deserialize the XML, the data in the List<T> disappears and I am left with an empty List<T> . I am not receiving any errors and the serialization portion works like charm. What am I missing with the deserialization process? EDIT: Note

Does rti/FastXml, or anything like it, work with rails 3 to speed-up xml rendering?

守給你的承諾、 提交于 2020-01-03 05:58:18
问题 We have a REST api implemented in rails 3 , which is using the yajl back-end for json . It is currently generating json responses significantly faster than xml when serializing more than about 20 rows. My next thought was that there must be a similar C-library drop-in for rail 3, which would use libxml or similar for to_xml , just as we're already using libyajl for to_json . To date, I've found only the rti/FastXml project: https://github.com/rti/FastXml It claims to be what I want, but hasn

Delphi 2010 DeHL Serialization XML and custom attribute : how it work?

落爺英雄遲暮 提交于 2020-01-02 21:47:12
问题 I try to investigate DeHL with Delphi 2010 custom attribute and I get problem. TAppParamTest = class public User: string; Password: string; end; TAppParam = class private FTest: TAppParamTest; public constructor Create; destructor Destroy; override; property Test: TAppParamTest read FTest write FTest; end; this works well : when I serialize I have this <TAppParam xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:DeHL="http://alex.ciobanu

How to deserialize xml using XmlArrayItem

做~自己de王妃 提交于 2020-01-02 19:12:33
问题 I want to deserialize xml like this: <Product> <Classification> <NewClassification>1</NewClassification> <NewClassification>2</NewClassification> <NewClassification>3</NewClassification> <OldClassification>A</OldClassification> <OldClassification>B</OldClassification> </Classification> </Product> My classes are: public class Product { public Classification Classification { get; set; } } public class Classification { [XmlArrayItem(typeof(int), ElementName = "NewClassification")] public List

XML deserialization fail

天涯浪子 提交于 2020-01-02 18:34:18
问题 I am deserializing the following XML file. Using XML serializer with VSTS 2008 + C# + .Net 3.5. Here is the XML file. <?xml version="1.0" encoding="utf-8"?> <Person><Name>=b?olu</Name></Person> Here is the screen snapshot for the display of the XML file and binary format of the XML file, If there are some solutions to accept such characters, it will be great! Since my XML file is big, and if such characters are really invalid and should be filtered, I want to keep remaining content of XML

Portable Class Library, XmlAnyElementAttribute

放肆的年华 提交于 2020-01-02 16:22:07
问题 In a Portable Class Library , I have a class that contains a member with an XmlAnyElement attribute. public partial class VariableWebServiceResponse { private List<System.Xml.XmlElement> anyField; public VariableWebServiceResponse () { this.anyField = new List<System.Xml.XmlElement>(); } [System.Xml.Serialization.XmlAnyElementAttribute(Order=0)] public List<System.Xml.XmlElement> Any { get { return this.anyField; } set { this.anyField = value; } } } This type of class works perfectly in .NET

How to create c# objects using xml

大憨熊 提交于 2020-01-02 09:29:13
问题 I am new to C#, Silverlight 5 and XAML beginner. I am working on a VS-2012 project and I don't have to use any CycleClip Board Ring to do this task. I have an XML file in my VS project. Suppose the file is given below: FileName is FileXml.xml <?xml version="1.0" encoding="utf-8" ?> <parameter> <name>mounts</name> <unit></unit> <component> <type>List</type> <attributes> <type>Integer</type> <displayed>4</displayed> <add_remove>yes</add_remove> <item>25</item> </attributes> <attributes>