xmlserializer

How to use XmlSerializer to serialize derived instances?

巧了我就是萌 提交于 2020-08-08 07:25:43
问题 I realize this looks to be an exact duplicate of Using XmlSerializer to serialize derived classes, but I cannot figure out how to get this working following the guidance from that same question: using System; using System.Text; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; namespace xmlSerializerLab { public class Utf8StringWriter : System.IO.StringWriter { public override Encoding Encoding => Encoding.UTF8; } [XmlRoot(ElementName = "Query", Namespace = "http:/

A better XML Serializer for Python 3

╄→尐↘猪︶ㄣ 提交于 2020-06-29 06:42:18
问题 I tried xml_marshaller as follows: from xml_marshaller import xml_marshaller class Person: firstName = "John" lastName = "Doe" person1 = Person() strXmlPerson = xml_marshaller.dumps(person1); print(strXmlPerson) The output from above is: b'<marshal><object id="i2" module="__main__" class="Person"><tuple/><dictionary id="i3"><string>firstName</string><string>John</string><string>lastName</string><string>Doe</string></dictionary></object></marshal>' which when formatted looks like this, which

C# Xml Serializer deserializes list to count of 0 instead of null

孤街醉人 提交于 2020-06-14 06:23:27
问题 I am confused on how XmlSerializer works behind the scenes. I have a class that deserializes XML into an object. What I am seeing is for the following two elements that are NOT part of the Xml being deserialized. [XmlRootAttribute("MyClass", Namespace = "", IsNullable = false)] public class MyClass { private string comments; public string Comments { set { comments = value; } get { return comments; } } private System.Collections.Generic.List<string> tests = null; public System.Collections

How to add an attribute which contains colon(:)for xml element and then serialize it in groovy?

99封情书 提交于 2020-03-25 19:14:10
问题 I have some test code snippet: ​import groovy.xml.XmlUtil class Greet { Greet() { } def salute() { println "Hello !" def input = """ <manifest xmlns:android="http://schemas.android.com/apk/res/android"> <application > <activity android:name="me.aolphn.MainActivity"> </activity> </application> </manifest> """ // def root = new XmlParser(false, true).parseText(input) def root = new XmlSlurper(false, true).parseText(input) root.'application'.@'android:txt'='this is txt' XmlUtil.serialize(root) }

C# XML deserialization

邮差的信 提交于 2020-02-06 02:43:30
问题 I have xml that is returned with an array of different types of objects. I am having trouble with the xmlchoiceidentifier when it gets to the keyword struct. When it deserializes it, it just returns null. Here is the xml that I am trying to deserialize: <struct> <member> <name>result</name> <value><boolean>1</boolean></value> </member> <member> <name>user_info</name> <value> <struct> <member> <name>First Name</name> <value><string>John</string></value> </member> <member> <name>Last Name</name

XmlSerializer bug when serializing collection of collections without root element?

假如想象 提交于 2020-01-25 16:38:57
问题 This is a bit of a long question, but I've made it as terse as possible, so please bear with me. It looks to me like a bug in the XmlSerializer class but before I file it with Microsoft I'd like to see if there's anything I've missed, which is entirely possible. I'm attempting to generate the following XML as a representative case, which is essentially a collection of collections, but where the outer collection has additional elements: <Links> <Name /> <Group> <Link /> <Link /> </Group>

Why does XmlSerializer NOT cause FileNotFoundException in Visual Studio 2019? [closed]

爱⌒轻易说出口 提交于 2020-01-24 09:06:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 9 days ago . So I originally encountered the issue described in this question: XmlSerializer giving FileNotFoundException at constructor However, we just upgraded from Visual Studio (VS) 2013 Pro to VS 2019 Pro. Now, when I have all Common Language Runtime (CLR) Exceptions turned on (break when thrown) including System.IO

Why does XmlSerializer NOT cause FileNotFoundException in Visual Studio 2019? [closed]

别说谁变了你拦得住时间么 提交于 2020-01-24 09:04:49
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 9 days ago . So I originally encountered the issue described in this question: XmlSerializer giving FileNotFoundException at constructor However, we just upgraded from Visual Studio (VS) 2013 Pro to VS 2019 Pro. Now, when I have all Common Language Runtime (CLR) Exceptions turned on (break when thrown) including System.IO

Keep sort when deserialize and serialize XML using XmlSerializer

雨燕双飞 提交于 2020-01-21 18:51:56
问题 I have the following test XML string: <?xml version="1.0" encoding="UTF-8"?> <test id="myid"> <b>b1</b> <a>a2</a> <a>a1</a> <b>b2</b> </test> which I deserialize using this class: [XmlRoot(ElementName = "test")] public class Test { [XmlElement(ElementName = "a")] public List<string> A { get; set; } [XmlElement(ElementName = "b")] public List<string> B { get; set; } [XmlAttribute(AttributeName = "id")] public string Id { get; set; } } If I'm now going to serialize the object the result will be