I was very confused about the how to set xmlns to be the first attribute, I used below code to generate a xml file
XNamespace ns = "http://www.openarchives.org/OAI/2.0/";
XNamespace xsiNs = "http://www.w3.org/2001/XMLSchema-instance";
XDocument xDoc = new XDocument(
new XDeclaration("1.0", "UTF-8", "no"),
new XElement(ns + "gpx",
new XAttribute(XNamespace.Xmlns + "xsi", xsiNs),
new XAttribute(xsiNs + "schemaLocation",
"http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd"),
));
howevery, the result is always
<?xml version="1.0" encoding="UTF-8"?>
<gpx
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://
www.openarchives.org/OAI/2.0/OAI-PMH.xsd"
xmlns="http://www.openarchives.org/OAI/2.0/">
I mean Iwwant xmlns="http://www.openarchives.org/OAI/2.0/" at the first. so when I call xElement.FirstAttribute, it should be xmlns rather than xmlns:xsi, any idea?