开发者

Delphi DeHL Deserialize XML File in newer class?

开发者 https://www.devze.com 2023-01-18 10:52 出处:网络
I use DeHL to serilize XML and class in Delphi and if add property to my class and try to deserialize my XML file. I have this error : ‘Deserializing « \\TApp\\FObject\\test » failed. Serializer re

I use DeHL to serilize XML and class in Delphi and if add property to my class and try to deserialize my XML file. I have this error : ‘Deserializing « \TApp\FObject\test » failed. Serializer re开发者_StackOverflow社区ported it’s missing or other entity is currently read!’.

I understand quite well this problem but is there a way to put default value instead of error ?


Alex answer me this :

You should be able to — by annotating the “part2″ field with [XmlNullable]. This will tell the XML serializer to set the “part2″ field to NIL if it does not have an XML node.

Note that while this is possible it’s not recommended. Deserialized content should be serialized back to the original types otherwise “bad things” may happen.

I ask this question a long time ago on his site but I was not able to find where I ask this question : http://alex.ciobanu.org/?p=285#comments

0

精彩评论

暂无评论...
验证码 换一张
取 消