sharpkml icon indicating copy to clipboard operation
sharpkml copied to clipboard

How to read extended KML if extension contains List

Open tothalexlaszlo opened this issue 3 years ago • 0 comments

Assume we have the following KML extract:

<Document>
    <ext:FeatureExtension>
			<ext:security>
				<ext:name>security xxx</ext:name>
				<ext:country>ESP</ext:country>
				<ext:country>ITA</ext:country>
			</ext:security>
    </ext:FeatureExtension>
</Document>

the models are:

[KmlElement(nameof(FeatureExtension), Constants.XmlNamespace)]
public class FeatureExtension : Element
{
   [KmlElement("security", Constants.XmlNamespace)]
   public Security? Security { get; set; }
}

[KmlElement("security", Constants.XmlNamespace)]
public class Security : Element
{
   [KmlElement("name", Constants.XmlNamespace)]
   public string Name { get; set; }

   [KmlElement("country", Constants.XmlNamespace)]
   public List<string> Country { get; set; }
}

// the KML extension registration
KmlFactory.RegisterExtension<Feature, FeatureExtension>();
KmlFactory.RegisterExtension<FeatureExtension, Security>();

The security tag isn't read in correctly all the country tags are missing. How should it be done? Thanks for any suggestion.

tothalexlaszlo avatar Apr 29 '22 06:04 tothalexlaszlo