<?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>KmlFile</name>
<open>1</open>
<Style id="sh_ylw-pushpin">
<IconStyle>
<scale>2</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>
<LineStyle>
<color>ff0000aa</color>
</LineStyle>
</Style>
<StyleMap id="msn_ylw-pushpin">
<Pair>
<key>normal</key>
<styleUrl>C:/Users/Administrator/Desktop/新建文本文档.kml#sn_ylw-pushpin</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>C:/Users/Administrator/Desktop/新建文本文档.kml#sh_ylw-pushpin</styleUrl>
</Pair>
</StyleMap>
<GroundOverlay>
<name>未命名图像叠加层</name>
<Icon>
<href>D:/备份/图片/HM9.GIF</href>
<viewBoundScale>0.75</viewBoundScale>
</Icon>
<LatLonBox>
<north>35.25598141413654</north>
<south>35.23913581589419</south>
<east>115.3612677572053</east>
<west>115.340422959514</west>
<rotation>355.0311840005118</rotation>
</LatLonBox>
</GroundOverlay>
<GroundOverlay>
<name>未命名图像叠加层</name>
<Icon>
<href>D:/备份/图片/HM9.GIF</href>
<viewBoundScale>0.75</viewBoundScale>
</Icon>
<LatLonBox>
<north>35.268975</north>
<south>35.25290277777778</south>
<east>115.4115194444444</east>
<west>115.3938166666667</west>
</LatLonBox>
</GroundOverlay>
</Document>
</kml>

解决方案 »

  1.   

    zhoukang0916 您好
    我这个文件是标准的xml文档吗 能被解析吗 
    我是新手 请您帮我 谢谢
      

  2.   

    XElement po = XElement.Load("c:/a.xml"); 
    IEnumerable <XElement> childElements = 
      from el in po.Descendants("Title") 
        select el; 
    foreach (XElement el in childElements) 
        Console.WriteLine((string)el); 
    Console.ReadLine(); 
        System.Xml.XmlDocument dom = new System.Xml.XmlDocument();
                dom.LoadXml(xml);
                foreach (System.Xml.XmlNode node in dom.ChildNodes)
                {   
                    if(node.Name !="xml")
                    Response.Write(GetNode(node)+"");            
                }  
            }        string GetNode(System.Xml.XmlNode node)
            {
                string str = node.InnerText;
                if (node.HasChildNodes)
                {
                    str = "";
                    foreach (System.Xml.XmlNode n in node.ChildNodes)
                    {
                        str += GetNode(n);
                    }
                }
                return str;
            }
    使用XmlTextReader方法很多
      

  3.   

    wuyq11(人生如梦)您好!我想问一下你
    网上很多例子都是这样解析Xml文件
    XmlDocument doc = new XmlDocument();
    doc.Load("c:\\xml\\google.xml");    //以上数据在c:\\xml\\google.xml文件里
    XmlNode xn = doc.SelectSingleNode("kml/Document");  像以上三行代码就可以解析google.xml文件 xn就得到<Document>元素 
    但我试了不行 但我以这种格式试了别的XML文件就行我不知道是不是因为google.xml文件有命名空间请您帮我解答一下  非常感谢