Intento crear un documento XML de GPX por LINQ a XML.Crear documento XML por LINQ, agregar xmlns, xmlns: xsi a él
Todo funciona muy bien, excepto al agregar atributos xmlns, xmlns: xsi al documento. Al intentarlo de manera diferente, obtengo excepciones diferentes.
Mi código:
XDocument xDoc = new XDocument(
new XDeclaration("1.0", "UTF-8", "no"),
new XElement("gpx",
new XAttribute("creator", "XML tester"),
new XAttribute("version","1.1"),
new XElement("wpt",
new XAttribute("lat","7.0"),
new XAttribute("lon","19.0"),
new XElement("name","test"),
new XElement("sym","Car"))
));
La salida también debe contener lo siguiente:
xmlns="http://www.topografix.com/GPX/1/1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
¿Cómo puedo añadir que por LINQ to XML? Intenté varias maneras, pero no funciona, excepciones durante el tiempo de compilación.
Estaba buscando exactamente este "xsi: schemaLocation". ¡Gracias! –