linq to xml - preventing unnecessary namespace into xml -


I am working on a project which modifies a kmi file by adding GPS coordinates to a specific location in kml. Although my code is adding the name "gx" to the all end of the saved elements, I have researched and have seen a million different Visual Basic XML writing methods and I have participated in ideas How can I stop adding unnecessary namespaces ?!

test.kml:

  & lt ;? Xml version = "1.0" encoding = "UTF-8" standalone =? "Yes" & gt; & Lt; Kml xmlns = "http://www.opengis.net/kml/2.2" xmlns: gx = "http://www.opengis.net/kml/2.2" & gt; & Lt; Document & gt; & Lt; Name & gt; Test.kml & lt; / Name & gt; & Lt; Snippet & gt; File created Monday 9 July 15:50:16 2012 & lt; / Snippet & gt; & Lt; Style id = "multitrack_n" & gt; & Lt; IconStyle & gt; & Lt; Symbols & gt; & Lt; Href & gt; Http: //maps.google.com/mapfiles/kml/shapes/track.png< / Href & gt; & Lt; / Symbol & gt; & Lt; / IconStyle & gt; & Lt; LineStyle & gt; & Lt; Color & gt; 99ffac59 & lt; / Color & gt; & Lt; Width & gt; 6 & lt; / Width & gt; & Lt; / LineStyle & gt; & Lt; / Style & gt; & Lt; Folder & gt; & Lt; Placemark & ​​gt; & Lt; Name & gt; Test.kml & lt; / Name & gt; & Lt; StyleUrl & gt; # MultTrack_n & lt; / StyleUrl & gt; & Lt; Gx: track & gt; & Lt ;! - GPS tracking data issue - & gt; & Lt; / Gx: track & gt; & Lt; / Placemark & ​​gt; & Lt; / Folder & gt; & Lt; / Documents & gt; & Lt; / Kml & gt;   

Code:

  Import System. IoO import system XML import system DataTime Import & lt; Xmlns = "http://www.opengis.net/kml/2.2"> Import & lt; Xmlns: gx = "http://www.opengis.net/kml/2.2" & gt; ... the public sub-add-corridant (double as double-line, doubled as double valve at double, as well as double etched in the form of timestamp string) slow current doc = XDocument.Load (" Test.kml ") when the element = _ & lt; When & gt; & Lt; % = Timestamp% & gt; & Lt; / When & gt; Coordinate = _ & lt; Gx: coordinate & gt; & Lt;% = lon.ToString%>, & lt;% = lat.ToString%>, & lt;% = att.ToString% & gt; & Lt; / Gx: Sync & gt; Dim testLocation = currentDoc & Lt; Kml & gt; & Lt; Document & gt; & Lt; Folder & gt; & Lt; Placemark & ​​gt; Elements.list () test location. Add (when the element) testlocation.Add (coordElement) currentDoc.Save ("test.kml") as the Captain in the form of the expansion console. Try the end (publishing) end end   

After the code:

  & lt ;? Xml version = "1.0" encoding = "UTF-8" standalone = "yes"? & Gt; & Lt; Gx: km l xmlns = "http://www.opengis.net/kml/2.2" xmlns: gx = "http://www.opengis.net/kml/2.2" & gt; & Lt; Gx: document & gt; & Lt; Gx: name & gt; Test.kml & lt; / Gx: name & gt; & Lt; Gx: snippet & gt; File created Monday 9th July 16:40:11 2012 & lt; / Gx: Snippet & gt; & Lt; Gx: style id = "multtrack_n" & gt; & Lt; Gx: IconStyle & gt; & Lt; Gx: sign & gt; & Lt; Gx: href & gt; Http: //maps.google.com/mapfiles/kml/shapes/track.png< / Gx: href & gt; & Lt; / Gx: sign & gt; & Lt; / Gx: IconStyle & gt; & Lt; Gx: LineStyle & gt; & Lt; Gx: color & gt; 99ffac59 & lt; / Gx: color & gt; & Lt; Gx: width & gt; 6 & lt; / Gx: width & gt; & Lt; / Gx: LineStyle & gt; & Lt; / Gx: style & gt; & Lt; Gx: folder & gt; & Lt; Gx: name & gt; Test.kml & lt; / Gx: name & gt; & Lt; Gx: placemark & ​​gt; & Lt; Gx: name & gt; Trial & lt; / Gx: name & gt; & Lt; Gx: styleUrl & gt; # MultTrack_n & lt; / Gx: styleUrl & gt; & Lt; Gx: track & gt; & Lt ;! - GPS tracking data issue - & gt; & Lt; When xmlns = "http://www.opengis.net/kml/2.2" & gt; 2012-07-09T08: 40: 29Z & lt; / When & gt; & Lt; Gx: Coordination xmlns: gx = "http://www.opengis.net/kml/2.2" & gt; 0,0,0 & lt; / Gx: Sync & gt; & Lt; When xmlns = "http://www.opengis.net/kml/2.2" & gt; 2012-07-09T08: 40: 33Z & lt; / When & gt; & Lt; Gx: Coordination xmlns: gx = "http://www.opengis.net/kml/2.2" & gt; 0,0,0 & lt; / Gx: Sync & gt; & Lt; When xmlns = "http://www.opengis.net/kml/2.2" & gt; 2012-07-09T08: 40: 41Z & lt; / When & gt; & Lt; Gx: Coordination xmlns: gx = "http://www.opengis.net/kml/2.2" & gt; 0,0,0 & lt; / Gx: Sync & gt; & Lt; / Gx: track & gt; & Lt; / Gx: Placemark & ​​gt; & Lt; / Gx: folder & gt; & Lt; / Gx: document & gt; & Lt; / Gx: kml & gt;    

After feeling what has been said in the comments, I realized that my Near the default NS XML, each element is assumed, so when I save it again, it applies to namespace

Something so small and simple ... I'm stupid ... Learn something everyday

Comments