xml-serialization

Deserialising XML based on attribute values

倖福魔咒の 提交于 2020-01-06 18:09:00
问题 I have some XML that I need to deserialise <element> <childElement key="myKey1">a value</childElement> <childElement key="myKey2">another value</childElement> </element> Into a class like [XmlRoot(ElementName="element")] public class Element { public string MyKey1 { get; set; } public string MyKey2 { get; set; } } Is it possible for me to annotate MyKey1 and MyKey2 so that if the xml above is deserialised then MyKey1 will be "a value" and MyKey2 will equal "another value"? If not then what is

generate xml file from oracle table

混江龙づ霸主 提交于 2020-01-06 08:32:53
问题 when I ran below store procedure then it shows error. here some special char related issue ,so i cant generate xml file , here xml format same as generate XML from oracle tables Connecting to the database DB_old. ORA-29285: file write error ORA-06512: at "SYS.UTL_FILE", line 148 ORA-06512: at "SYS.UTL_FILE", line 889 ORA-06512: at "DBO_17FEB.EXPOR1", line 60 ORA-06512: at line 6 Process exited. Disconnecting from the database DB_old. ------------------- create or replace PROCEDURE Expor1 ( V

generate xml file from oracle table

会有一股神秘感。 提交于 2020-01-06 08:30:33
问题 when I ran below store procedure then it shows error. here some special char related issue ,so i cant generate xml file , here xml format same as generate XML from oracle tables Connecting to the database DB_old. ORA-29285: file write error ORA-06512: at "SYS.UTL_FILE", line 148 ORA-06512: at "SYS.UTL_FILE", line 889 ORA-06512: at "DBO_17FEB.EXPOR1", line 60 ORA-06512: at line 6 Process exited. Disconnecting from the database DB_old. ------------------- create or replace PROCEDURE Expor1 ( V

XML Deserialization - convert attribute value into class automatically (.net)

南笙酒味 提交于 2020-01-06 04:42:27
问题 (vb.net/c#/etc) I am having trouble figuring out how to do a bit of deserialization magic. Currently the standard deserialization works fine, including the enums, but now I want to convert an attribute into a class. Oh! what was I thinking ! My xml looks a bit like this: .... <review user="..." version="2.2">...</review> And this for my property/class: [XmlAttribute("version")] public MyVersion Version { get; set; } class MyVersion { // equality overloaded // can ctype() from string to

XmlDictionaryReader reading fixed-size zeroed Stream

ぃ、小莉子 提交于 2020-01-04 12:48:57
问题 Can someone give me good explanation why this has to fail? const int bufferSize = 2 * 1024, testValue = 123456; var buffer = new byte[bufferSize]; var serializer = new DataContractSerializer(typeof(int)); //Serialize value using (var memStream = new MemoryStream(buffer)) using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateBinaryWriter(memStream)) serializer.WriteObject(writer, testValue); //Deserialize value using (var memStream = new MemoryStream(buffer)) using (XmlDictionaryReader

XmlDictionaryReader reading fixed-size zeroed Stream

我怕爱的太早我们不能终老 提交于 2020-01-04 12:48:53
问题 Can someone give me good explanation why this has to fail? const int bufferSize = 2 * 1024, testValue = 123456; var buffer = new byte[bufferSize]; var serializer = new DataContractSerializer(typeof(int)); //Serialize value using (var memStream = new MemoryStream(buffer)) using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateBinaryWriter(memStream)) serializer.WriteObject(writer, testValue); //Deserialize value using (var memStream = new MemoryStream(buffer)) using (XmlDictionaryReader

Tweak output from XmlSerializer in C#

人走茶凉 提交于 2020-01-04 11:12:32
问题 I am wondering if there is a way to get XmlSerializer in C# to change what it outputs for one property of one object. For example, if I have something like: public class MyClass { public string prop1{get;} public uint prop2{get;} public MyClass2 class2{get;} public MyClass3 class3{get;} } public class MyClass2 { public string prop3{get;} } public class MyClass3 { //Lots of properties that I want to serialize as normal } Now in somewhere in my code, I have something like this: private void

Tweak output from XmlSerializer in C#

人走茶凉 提交于 2020-01-04 11:12:26
问题 I am wondering if there is a way to get XmlSerializer in C# to change what it outputs for one property of one object. For example, if I have something like: public class MyClass { public string prop1{get;} public uint prop2{get;} public MyClass2 class2{get;} public MyClass3 class3{get;} } public class MyClass2 { public string prop3{get;} } public class MyClass3 { //Lots of properties that I want to serialize as normal } Now in somewhere in my code, I have something like this: private void

Using C# xmlserializer on derived classes while controlling the generated XML element

为君一笑 提交于 2020-01-04 09:09:22
问题 I've got a C# structure of classes with an abstract base class and various classes derived from this abstract class. [System.Xml.Serialization.XmlInclude(typeof(B))] public abstract class A { ... } [Serializable] [XmlType("typename")] public class B : A { ... } Furthermore, I'm using an instance of class B within another class C as a field with its abstract type like this: public class C { ... public A myItem { get; set; } //A is actually of type B ... } Now, when I serialize my class C via

Using C# xmlserializer on derived classes while controlling the generated XML element

折月煮酒 提交于 2020-01-04 09:09:11
问题 I've got a C# structure of classes with an abstract base class and various classes derived from this abstract class. [System.Xml.Serialization.XmlInclude(typeof(B))] public abstract class A { ... } [Serializable] [XmlType("typename")] public class B : A { ... } Furthermore, I'm using an instance of class B within another class C as a field with its abstract type like this: public class C { ... public A myItem { get; set; } //A is actually of type B ... } Now, when I serialize my class C via