I ran into another KML project but apparently it started and stopped in 2006, was for KML 2.0 and it missed deserializing. Also the author was kind of doing manual serialization rather than take advantage of the .NET Xml serialization.
I briefly examined this project and seems oke, and it has some documentation!!! I am apalled to see how many people out there put their pet projects on SourceForge and do not even provide documentation. That is one of those things that in my opinion differentiates a mere programmer from a software professional.
Do you think you will be adding support to deserialize KML in your project? I am using a tool for developing Microsoft Simulator X scenery that integrates with GE, you edit the KML with GE and then reload it with the application, then send it back to GE and so on. It is just fantastic. So, I am also writing a tool that needs to integrate with GE but for that I need to be able to read the GE-generated KML file as well. Only the tool is merely interested in Point/Polygon and LineString types of geometries.
Actually I have been looking at your code and with some strategy you can do a pretty decent KML deserializer.
- You need the System.Xml.Serialization namespace
- All your classes that get (de)serialized MUST include a parameterless constructor
- I believe the .NET Ser/Deser searches for public Properties (as opposed to public fields. So basically you might need to encapsulate your stuff which is actually a good practice, don't know why you didn't do it right from the start.
- Mark your class with the [Serializable] attribute
- The public properties that must not get (de)serialized mark with [XmlIgnore]
- Public properties that get serialized to an element: [XmlElement]
- Public properties that get serialized to XML element attribute: [XmlAttribute]
- And for arrays you can use [XmlArray] if you are to encapsulate them.
Really, it saves you a lot of work and pain from doing manual serialization.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.