xml-deserialization

Unexpected node type Element

折月煮酒 提交于 2021-01-27 08:32:09
问题 I have the following XML : <Envelope> <Body> <RESULT> <SUCCESS>TRUE</SUCCESS> <RecipientId>9876543210</RecipientId> <ORGANIZATION_ID>12345-67890-b9e6bcd68d4fb511170ab3fcff55179d</ORGANIZATION_ID> </RESULT> </Body> </Envelope> Which I'm trying to deserialize to: [XmlRoot(ElementName = "Envelope")] public class Add_Recipent_response { public string Body { get; set; } public string RESULT { get; set; } public string SUCCESS { get; set; } public string RecipientId { get; set; } public string

Deserializing xml, including namespace

我只是一个虾纸丫 提交于 2021-01-02 06:17:23
问题 I am trying to deserialize some XML and I can't get the namespace / xsi:type="Model" to work. If xsi:type="Model" is left out of the XML it works, but it has to be there. If I leave the namespace out of my Model, I get an error, if I rename it, I get an empty list. XML <Vehicles xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Vehicle xsi:type="Model"> <Id>238614402</Id> </Vehicle> <Vehicle xsi:type="Model"> <Id>238614805</Id> </Vehicle> <

Deserializing xml, including namespace

风流意气都作罢 提交于 2021-01-02 06:15:26
问题 I am trying to deserialize some XML and I can't get the namespace / xsi:type="Model" to work. If xsi:type="Model" is left out of the XML it works, but it has to be there. If I leave the namespace out of my Model, I get an error, if I rename it, I get an empty list. XML <Vehicles xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Vehicle xsi:type="Model"> <Id>238614402</Id> </Vehicle> <Vehicle xsi:type="Model"> <Id>238614805</Id> </Vehicle> <

Unexpected node type element error when deserialising

北战南征 提交于 2020-07-31 03:36:11
问题 I'm attempting to parse a large Japanese to English dictionary written in XML. A typical entry looks like this: <entry> <ent_seq>1486440</ent_seq> <k_ele> <keb>美術</keb> <ke_pri>ichi1</ke_pri> <ke_pri>news1</ke_pri> <ke_pri>nf02</ke_pri> </k_ele> <r_ele> <reb>びじゅつ</reb> <re_pri>ichi1</re_pri> <re_pri>news1</re_pri> <re_pri>nf02</re_pri> </r_ele> <sense> <pos>&n;</pos> <pos>&adj-no;</pos> <gloss>art</gloss> <gloss>fine arts</gloss> </sense> <sense> <gloss xml:lang="dut">kunst</gloss> <gloss xml

Using XML decorations to specify default values during de-serialization

久未见 提交于 2020-06-09 16:57:11
问题 I have a problem deserializing some XML; the XML supplied by a third party is quite verbose, so if there is no value set for an particular element, it will supply and empty element (e.g. <element1 /> ). This is a problem for certain elements, for example, those that are meant to store integers. I have control over the third party, so I could either get them to specify a default value ( <myinteger>0</myinteger> ) or I can get them to omit these elements entirely. Both of these should avoid the

Using XML decorations to specify default values during de-serialization

好久不见. 提交于 2020-06-09 16:56:09
问题 I have a problem deserializing some XML; the XML supplied by a third party is quite verbose, so if there is no value set for an particular element, it will supply and empty element (e.g. <element1 /> ). This is a problem for certain elements, for example, those that are meant to store integers. I have control over the third party, so I could either get them to specify a default value ( <myinteger>0</myinteger> ) or I can get them to omit these elements entirely. Both of these should avoid the

Using XML decorations to specify default values during de-serialization

亡梦爱人 提交于 2020-06-09 16:56:07
问题 I have a problem deserializing some XML; the XML supplied by a third party is quite verbose, so if there is no value set for an particular element, it will supply and empty element (e.g. <element1 /> ). This is a problem for certain elements, for example, those that are meant to store integers. I have control over the third party, so I could either get them to specify a default value ( <myinteger>0</myinteger> ) or I can get them to omit these elements entirely. Both of these should avoid the

How to deserialize Nullable<bool>? [duplicate]

旧城冷巷雨未停 提交于 2020-05-28 02:26:04
问题 This question already has answers here : Deserializing empty xml attribute value into nullable int property using XmlSerializer (4 answers) Closed 2 years ago . I am trying to deserialize a Nullable<bool> from my XML file. My expectation was that a XMLAttribute which was not found in my XMLElement is null and if it's found it will be true or false . Same for serialization. My variable will be written if it's not null. Anyways, everytime I'm trying to deserialize my XML an

How to deserialize Nullable<bool>? [duplicate]

。_饼干妹妹 提交于 2020-05-28 02:24:20
问题 This question already has answers here : Deserializing empty xml attribute value into nullable int property using XmlSerializer (4 answers) Closed 2 years ago . I am trying to deserialize a Nullable<bool> from my XML file. My expectation was that a XMLAttribute which was not found in my XMLElement is null and if it's found it will be true or false . Same for serialization. My variable will be written if it's not null. Anyways, everytime I'm trying to deserialize my XML an