如何读取kml文件中的特定值并在c#中设置它们

时间:2013-08-22 14:34:18

标签: c# xml kml

我正在尝试将kml文件中的纬度和经度设置为稍后要使用的变量。我是c#的新手,到目前为止只能读取整个文件。

我使用Excel创建了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>Earth Point Excel To KML</name>
    <open>1</open>
    <Snippet maxLines="1">Unity_walk_through.xlsx</Snippet>
    <description><![CDATA[Source: Unity_walk_through.xlsx<br/>DateTime: 2013-08-18 11:23:42 UTC<br/><br/>&copy;2013 Earth Point<br/><a target='_blank' href='http://www.earthpoint.us'>www.earthpoint.us</a><br/><br/>For illustration only.&nbsp; User to verify all information.]]></description>
    <Style>
        <IconStyle>
            <Icon>
            </Icon>
        </IconStyle>
        <BalloonStyle>
            <text>$[description]</text>
            <textColor>ff000000</textColor>
            <displayMode>default</displayMode>
        </BalloonStyle>
    </Style>
    <Style id="NormalSheet1Map1">
        <IconStyle>
            <Icon>
                <href>http://www.earthpoint.us/Dots/GoogleEarth/paddle/ltblu-diamond.png</href>
            </Icon>
        </IconStyle>
        <LabelStyle>
        </LabelStyle>
        <BalloonStyle>
            <text>$[description]</text>
        </BalloonStyle>
        <LineStyle>
            <color>ffff00ff</color>
            <width>2</width>
        </LineStyle>
        <PolyStyle>
            <color>00ff00ff</color>
            <fill>0</fill>
        </PolyStyle>
    </Style>
    <StyleMap id="Sheet1Map1">
        <Pair>
            <key>normal</key>
            <styleUrl>#NormalSheet1Map1</styleUrl>
        </Pair>
        <Pair>
            <key>highlight</key>
            <styleUrl>#HighlightSheet1Map1</styleUrl>
        </Pair>
    </StyleMap>
    <Style id="HighlightSheet1Map1">
        <IconStyle>
            <scale>1.1</scale>
            <Icon>
                <href>http://www.earthpoint.us/Dots/GoogleEarth/paddle/ltblu-diamond.png</href>
            </Icon>
        </IconStyle>
        <LabelStyle>
            <scale>1.1</scale>
        </LabelStyle>
        <BalloonStyle>
            <text>$[description]</text>
        </BalloonStyle>
        <LineStyle>
            <color>ffff00ff</color>
            <width>3</width>
        </LineStyle>
        <PolyStyle>
            <color>70ff00ff</color>
            <fill>0</fill>
        </PolyStyle>
    </Style>
    <Folder>
        <name>Sheet1</name>
        <Placemark>
            <name>&lt;b/&gt;</name>
            <Snippet maxLines="0"></Snippet>
            <LookAt>
                <longitude>-7.899325</longitude>
                <latitude>53.41568611</latitude>
                <altitude>0</altitude>
                <heading>0</heading>
                <tilt>0</tilt>
                <range>1000</range>
                <altitudeMode>relativeToGround</altitudeMode>
            </LookAt>
            <styleUrl>#Sheet1Map1</styleUrl>
            <Style>
                <LabelStyle>
                    <color>00000000</color>
                </LabelStyle>
            </Style>
            <ExtendedData>
            </ExtendedData>
            <Point>
                <coordinates>-7.899325,53.41568611000001,0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>&lt;b/&gt;</name>
            <Snippet maxLines="0"></Snippet>
            <LookAt>
                <longitude>-7.8991</longitude>
                <latitude>53.41593611</latitude>
                <altitude>0</altitude>
                <heading>0</heading>
                <tilt>0</tilt>
                <range>1000</range>
                <altitudeMode>relativeToGround</altitudeMode>
            </LookAt>
            <styleUrl>#Sheet1Map1</styleUrl>
            <Style>
                <LabelStyle>
                    <color>00000000</color>
                </LabelStyle>
            </Style>
            <ExtendedData>
            </ExtendedData>
            <Point>
                <coordinates>-7.8991,53.41593611,0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>&lt;b/&gt;</name>
            <Snippet maxLines="0"></Snippet>
            <LookAt>
                <longitude>-7.900325</longitude>
                <latitude>53.41701111</latitude>
                <altitude>0</altitude>
                <heading>0</heading>
                <tilt>0</tilt>
                <range>1000</range>
                <altitudeMode>relativeToGround</altitudeMode>
            </LookAt>
            <styleUrl>#Sheet1Map1</styleUrl>
            <Style>
                <LabelStyle>
                    <color>00000000</color>
                </LabelStyle>
            </Style>
            <ExtendedData>
            </ExtendedData>
            <Point>
                <coordinates>-7.900325,53.41701111,0</coordinates>
            </Point>
        </Placemark>
    </Folder>
</Document>
</kml>

0 个答案:

没有答案