views:

115

answers:

1

Hi all,

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 reported 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 ?

+2  A: 

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

Hugues Van Landeghem