简体   繁体   中英

c# xml serialization with XmlAttribute tag

I am trying to serialize an object using XmlSerializer. The input class that has a property with [XmlAttribute] is not showing up in output xml. Anyway to fix this?

For it not to appear at all, one of these things is usually true:

  • the type is not appropriately accessible; for typical values, this means that it needs a public getter and setter; if it lacks both: it will not be serialized (note that for collections, only a getter is required)
  • conditional serialization of some form is enabled (either via [DefaultValue] , or a ShouldSerialize*() method), and is indicating to omit it
  • it is being fully ignored ( [XmlIgnore] , for example)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM