Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Problem changing class field from string to Class

Problem changing class field from string to Class

Scheduled Pinned Locked Moved XML / XSL
help
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jason Pease
    wrote on last edited by
    #1

    I am maintaining an application that uses the XmlSerializer to import and export data. I would like to make some modifications to the internals of the application, but I need to maintain backward compatibility with older XMLs that customers may have. Essentially I'm trying to change [XmlAttribute] public string CashFlowType; , which contains the name of the type, to this [XmlAttribute] public CashFlowType CashFlowType; , which would be an object that encapsulates all of the details of the object instead of just the name. The problem is that the Serializer can't put the complex type CashFlowType into an XmlAttribute, and rightly so. The ideal solution would be to use [XmlElement] and write out the fields that I need to deserialize, but for the sake of maintaining backward compatibility, I cannot change the attribute to an element. I have tried setting all of the fields of CashFlowType to [XmlIgnore] and I overrode ToString() in the hopes that the serializer would put the result of ToString in the attribute but it throws an exception just the same. If anyone has any ideas it would be greatly appreciated. Thanks, Jason

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups