loading a kml file

May 10, 2013 at 3:27 PM
Hello,
I would like to know how to load a kml file from the local disk. I searched on the internet regarding this but went in vain.

Thanks in advance.
Coordinator
May 11, 2013 at 11:08 AM
I've created a new page in the documentation which might be able to help in this regard - let me know of any problems:

Extracting information from a Kml file

Sam
Jul 23, 2013 at 10:06 PM
The kml is null for me. I'm trying this way:
        MemoryStream stream = new MemoryStream(kmlfile);
        var file = SharpKml.Engine.KmlFile.Load(stream);
        SharpKml.Dom.Kml __kml__ = file.Root as SharpKml.Dom.Kml;
It's a usual kml file and this code gives null for kml.
Coordinator
Jul 24, 2013 at 5:45 AM
Two questions: is the root element of the Kml file a Kml element (doesn't have to be but most commonly is)? If not the cast won't work.

Second question, what namespace is being used by the Kml file? You may need to look at the Legacy Files page if it's non-standard.

Failing that can you post a snippet of the Kml file you are trying to load?
Aug 1, 2013 at 8:30 AM
Edited Aug 3, 2013 at 5:25 PM
a
Aug 1, 2013 at 8:58 AM
Your good... the your link added the answer.

thanks a lot
Aug 3, 2013 at 5:29 PM
Hi,

thanks for your answer. It helped in some cases.
Now I have kml files, which I can't read (with edit...) it seems they are coded, or something. It looks like this:
PK   olŃë† j  doc.kmlě˝kĎŻW‘Ţů>RľƒÇŃĽkěu>CDÓM„ęž@F‰˘(ÚŘ»Ťăí±7ćÓOýę^µŞţť†N+‡‰"laěg×sßë^‡Zu¸ęŞO˙ĺďóŐ˙ůí·ß}ůîë|˜?J~đöëĎŢ}ţĺ×_üŕĂóËź|o}ř/ How can I pars this with SharpKML? The parser gives me this:
' ', hexadecimal value 0x03, is an invalid character. Line 1, position 3.

Thanks,
L
Coordinator
Aug 3, 2013 at 7:01 PM
It looks like that might be a Kmz file, which is a compressed Kml file. The library should be able to handle those using the SharpKml.Engine.KmzFile class.

Sam