简体   繁体   中英

XML Dynamic Serialization / Deserialization

I've got an object whose XML structure is dynamic and can change runtime based on the Application.

What I would like to do is specify the XML Element location for each property's declaration. However, it seems this can not be done in runtime and needs to be statically set. Is there another method for accomplishing what I would want to do?

 public class user
 {
      [System.Xml.Serialization.XmlElement(XMLLocation.PersonUsername)]
      public String name;
 }

Since the data is the same but passed along to different applications I'd recommend using the same internal XML and processing it with XSLT before passing it along.

Implementing IXmlSerializable is certainly possible, so are other approaches, but you'll find yourself writing complex and unmaintainable code.

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