During this period of time, we are doing a task that is crawled from the network. map File and region image, load and locate the corresponding, and output the navigation path. kml format, so that the last path is displayed in the next load. If you have used Google Earth, you should know these two file formats .. Map File Parsing this file is not an XML file format, but it has an inherent output order. I only need to extract the information I want in a fixed order. Of course, I have the most stupid method here, this method is too versatile to intercept in the form of character lines, but I really don't know which method to use. If I know it, I still forget to tell ~ Fileopenpicker filepicker = new fileopenpicker ();
Filepicker. filetypefilter. Add (". Map ");
Filepicker. viewmode = pickerviewmode. thumbnail;
Storagefile file = await filepicker. picksinglefileasync ();
If (null! = File)
{
Ilist <string> filecontent = await fileio. readlinesasync (File );
...
}
. Kml File Parsing kml files are XML file formats, but there are subtle differences, it has header files <kml xmlns = "http://www.opengis.net/kml/2.2" xmlns: GX = "http://www.google.com/kml/ext/2.2" xmlns: kml = "http://www.opengis.net/kml/2.2" xmlns: Atom = "http://www.w3.org/2005/Atom">
In this format, the file cannot be loaded in C #. I took another step in the middle and replaced the xmlns: kml format with the normal XML file format, after reading the data, write it back to the file.
. Kml File Reading
View code
Fileopenpicker filepicker = new fileopenpicker ();
Filepicker. filetypefilter. Add (". kml ");
Filepicker. viewmode = pickerviewmode. thumbnail;
Storagefile file = await filepicker. picksinglefileasync ();
// Kml file escape
String filecontent = await fileio. readtextasync (File );
String newstr = filecontent. Replace ("xmlns:", "renew ");
Newstr = newstr. Replace ("xmlns", "topattr ");
Await fileio. writetextasync (file, newstr );
Filecontent = await fileio. readtextasync (File );
// Read the corresponding node in XML file format
....
// Restore the File Content
Newstr = newstr. Replace ("renew", "xmlns :");
Newstr = newstr. Replace ("topattr", "xmlns ");
After some twists and turns, my demand is met. I don't know if you have any better solutions?