XmlSerialization and xsi:SchemaLocation (xsd.exe)
c#, gpx, xml-serialization, xsd, xsd.exe
Solution
Add this to your generated C# class:
[XmlAttribute("schemaLocation", Namespace = XmlSchema.InstanceNamespace)]
public string xsiSchemaLocation = "http://www.topografix.com/GPX/1/1 " +
"http://www.topografix.com/GPX/1/1/gpx.xsd";
Apparently the `xsd.exe` tool does not generate the `schemaLocation` attribute.
Problem
I used xsd.exe to generate a C# class for reading/writing GPX files. How do I get the resultant XML file to include the xsi:schemaLocation attribute eg. I want the following but xsi:schemaLocation is always missing ``` <?xml version="1.0"?> <gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.1" xmlns="http://www.topografix.com/GPX/1/1" creator="ExpertGPS 1.1 - http://www.topografix.com" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"> </gpx> ```