makinacorpus / Leaflet.FileLayer

Loads files locally (GeoJSON, KML, GPX) as layers using HTML5 File API
http://makinacorpus.github.io/Leaflet.FileLayer/
MIT License
270 stars 91 forks source link

CDATA section ignored in KML description #17

Closed ghost closed 7 years ago

ghost commented 9 years ago

When I load a KML file the KML description is ignored when it's inside a CDATA section.

This works just fine,

      <description>
           Here is some text
      </description>

but not this one;

      <description>
        <![CDATA[
             Here is some text
        ]]>
      </description>

It seems an old issue in togeojson.js and should be fixed https://github.com/mapbox/togeojson/issues/42 Using the latest togeojson.js file doesn't solved my problem.

Is this a leaflet.filelayer issue or togeojson.js ?

Regards,

Robertico

leplatrem commented 9 years ago

Hi Robertico !

This part parses the XML into nodes and gives it to togeojson : https://github.com/makinacorpus/Leaflet.FileLayer/blob/gh-pages/leaflet.filelayer.js#L80-L82

If the problem was fixed in togeojson, we might pass the raw XML instead of parsing it here...

Could you try to change this and see if it helps ?

Thanks for reporting!

ghost commented 9 years ago

Hi,

I'm not sure I understand you correctly. Do I need to comment out these lines? When I do so, it doesn't work at all.

Sorry, I'm not a professional programmer :-)

leplatrem commented 9 years ago

Well, I upgraded togeojson towards 0.8.1, and it works wel, it strips out CDATA out of texts !

ghost commented 9 years ago

I doubted my findings, but... this doesn't work.

      <description>
        <![CDATA[
             Here is some text
        ]]>
      </description>

but this does !

<description><![CDATA[Here is some text]]></description>

So it must be a single line without line breaks. As far as I know they're both valid. Nevertheless a bug?

leplatrem commented 9 years ago

In the example I tried it worked. But this way :

<description><![CDATA[

             Here is some text
]]></description>

Otherwise, it would be a bug in togeojson...

ghost commented 9 years ago

Thanks. Created a new issue on togeojson for this.

SBats commented 7 years ago

I close this issue. If someone has still problems with it please reopen !