I extracted the following node from XmlReader:
string xml = "<FeatureType xmlns=\"http://www.opengis.net/wfs\" > </FeatureType>"
In order to deserialize to a predefined class, I attempted:
using (StringReader elementReader = new StringReader("<?xml version='1.0'?>" + xml ))
{
// TODO: Can data contract serializer be used?
XmlSerializer deserializer = serializers[typeof(FeatureType)];
featureTypes.Add((FeatureType)deserializer.Deserialize(elementReader));
}
Upon deserialization, XmlSerializer throws an exception with the following message:
"<FeatureType xmlns='http://www.opengis.net/wfs'> was not expected."
If I remove the namespace declaration, I can deserialize. Without having to further manipulate with the output of the reader, how do I fix this? Also, why is the reader injecting the namespace declaration, when it extracts each node?
TIA.