惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
V
Vulnerabilities – Threatpost
G
GRAHAM CLULEY
Simon Willison's Weblog
Simon Willison's Weblog
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Privacy International News Feed
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Secure Thoughts
MyScale Blog
MyScale Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
V
Visual Studio Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
L
LINUX DO - 最新话题
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Cloudflare Blog
美团技术团队
Recorded Future
Recorded Future
T
Tailwind CSS Blog
Latest news
Latest news
Security Archives - TechRepublic
Security Archives - TechRepublic
Security Latest
Security Latest
Know Your Adversary
Know Your Adversary
Cloudbric
Cloudbric
Schneier on Security
Schneier on Security
I
Intezer
L
LINUX DO - 热门话题
P
Palo Alto Networks Blog
云风的 BLOG
云风的 BLOG
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Attack and Defense Labs
Attack and Defense Labs
人人都是产品经理
人人都是产品经理
L
LangChain Blog
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
博客园 - 叶小钗
L
Lohrmann on Cybersecurity
S
SegmentFault 最新的问题
W
WeLiveSecurity
C
Cybersecurity and Infrastructure Security Agency CISA
S
Securelist
SecWiki News
SecWiki News
V2EX - 技术
V2EX - 技术
IT之家
IT之家
Cyberwarzone
Cyberwarzone
F
Full Disclosure
Spread Privacy
Spread Privacy
阮一峰的网络日志
阮一峰的网络日志

博客园 - my favorite

【转】QT样式表 (QStyleSheet) 【转】Qt事件循环与线程 二 [转]Qt 智能指针学习 【转】Android Web Server 【转】Android Http Server Java Annotation 注释语法 android中json的序列化与反序列化 JavaScript定义类的几种方式 js获取浏览器高度和宽度值(多浏览器) Setting up SSL made easy… Better, Faster, Easier SSL testing for ASP.NET MVC & WebForms ASP.NET MVC 3 Internationalization Windows 8学习笔记(十二)--集合控件 Windows 8 学习笔记(十三)--生命周期 Windows 8学习笔记(十一)---图片的显示与保存 Windows 8 Metro App学习笔记(九)—磁砖 Windows 8学习笔记(十)----Notification Windows 8 学习笔记(八)--各种流之间的转换 Windows 8学习笔记(七)--Input输入设备
Windows 8 学习笔记(十四)--.map文件与.kml文件的解析
my favorite · 2012-07-03 · via 博客园 - my favorite

这段时间在做一个通过从网络上抓取的.map文件及区域图片,进行相应的加载定位,并将导航路径输出为.KML格式,以便下次加载显示上次路径。用过Google Earth的应该知道这两种文件格式。

.map文件解析

该文件不是XML文件格式,但却有固有的输出顺序,我只需按固定的顺序截取我要的信息即可,当然我这里有的最笨的方法,字符行的形式进行截取的,这个方法通用性太低,但我实在不知用哪种方式,若有知晓的,还忘告知~

复制代码

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文件解析

kml文件是XML文件格式,但有细微的区别,它有头文件

<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">

这样的格式C#中不能成功加载文件,我中间多走了一步去中转了下,将xmlns:kml格式先替换为正常的XML文件格式,等读取完成后再将其写回文件中去。 

.kml文件的读取 

 View Code

 

复制代码

FileOpenPicker filepicker = new FileOpenPicker();
                filepicker.FileTypeFilter.Add(".kml");
                filepicker.ViewMode = PickerViewMode.Thumbnail;
                StorageFile file = await filepicker.PickSingleFileAsync();
                //kml文件转义
                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);
        //按XML文件格式读取相应的节点

        。。。。
                
        //再将文件内容还原回去
        newstr = newstr.Replace("renew""xmlns:");
                newstr = newstr.Replace("topattr""xmlns");

复制代码

 几经周折,我的需求是满足了,不知道各位还有没有别的更好的方法呢?

Trackback:

http://www.cnblogs.com/jing870812/archive/2012/06/18/2553978.html