首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

c# asp.net 怎么取上面的kml文件

2012-11-07 
c# asp.net 如何取下面的kml文件如何用vs2008c# asp.net 读下面的kml文件只要Placemark的name和longitud

c# asp.net 如何取下面的kml文件
如何用vs2008 c# asp.net 读下面的kml文件
只要<Placemark>的name 和longitude latitude.
<name>1</name>
<LookAt>
<longitude>128.8574432157351</longitude>
<latitude>35.80600083716327</latitude>

(如果是xml, 会遇到gx:altitudeMode 这个地方总是提示错误)

以下是kml 文件如下

<?xml version="1.0" encoding="UTF-8"?>
<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">
<Document>
<name>mynew.kml</name>
<Style id="s_ylw-pushpin">
<IconStyle>
<scale>1.1</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<Style id="s_ylw-pushpin0">
<IconStyle>
<scale>1.1</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<Style id="s_ylw-pushpin_hl">
<IconStyle>
<scale>1.3</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<Style id="s_ylw-pushpin_hl0">
<IconStyle>
<scale>1.3</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<StyleMap id="m_ylw-pushpin">
<Pair>
<key>normal</key>
<styleUrl>#s_ylw-pushpin0</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#s_ylw-pushpin_hl0</styleUrl>
</Pair>
</StyleMap>
<StyleMap id="m_ylw-pushpin0">
<Pair>
<key>normal</key>
<styleUrl>#s_ylw-pushpin</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#s_ylw-pushpin_hl</styleUrl>
</Pair>
</StyleMap>
<Folder>
<name>mynew</name>
<open>1</open>
<Placemark>
<name>1</name>
<LookAt>
<longitude>128.8574432157351</longitude>
<latitude>35.80600083716327</latitude>
<altitude>0</altitude>
<heading>10.55660223235264</heading>
<tilt>0</tilt>
<range>1540192.185251366</range>
<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
</LookAt>
<styleUrl>#m_ylw-pushpin</styleUrl>
<Point>
<coordinates>121.8574432157351,35.80600083716327,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>2</name>
<LookAt>
<longitude>121.8574432157351</longitude>
<latitude>35.80600083716327</latitude>
<altitude>0</altitude>


<heading>10.55660223235264</heading>
<tilt>0</tilt>
<range>1540192.185251366</range>
<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
</LookAt>
<styleUrl>#m_ylw-pushpin</styleUrl>
<Point>
<coordinates>120.9816678435045,34.24708284303667,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>12</name>
<styleUrl>#m_ylw-pushpin0</styleUrl>
<LineString>
<tessellate>1</tessellate>
<coordinates>
122.1540721386445,35.91277900000853,0 121.9626481477574,35.65330325225175,0 121.7483994100895,35.12348728741795,0 121.6894296772687,34.61505415247737,0 121.5312363524981,34.31889606291347,0 121.2136947838886,34.21361692622873,0 121.1338691479457,34.43882187403595,0 
</coordinates>
</LineString>
</Placemark>
</Folder>
</Document>
</kml>


[解决办法]
注意有命名空间,参考:http://blog.csdn.net/fangxinggood/article/details/5978613
[解决办法]
xpath没写好
[解决办法]
按你的说法,通过coordinates的条件找name的方法

/x:Document/x:Folder/x:Placemark[x:Point/x:coordinates='114.4744460035643,30.59598487608687,0']/x:name

热点排行