Skip to main content

Hi Everyone, I have this KML and I cannot seem to figure out how to convert to shapefile without losing the data in html description field. Ideally, I want these to be parsed to attributes. Any help would be appreciated.

image

This can be done using the HTMLExtractor on kml_description. But this is not an easy transformer to work with.

 

An alternative is to use a FeatureReader to read the KML, FeatureWriter to write the kml_description to a temp text file and a FeatureReader HTML Table to read the table.


This can be done using the HTMLExtractor on kml_description. But this is not an easy transformer to work with.

 

An alternative is to use a FeatureReader to read the KML, FeatureWriter to write the kml_description to a temp text file and a FeatureReader HTML Table to read the table.

Attached working sample.

 


Hello @wam2014​ 

There is an article on extracting feature attributes from KML tags or HTML tables here that demonstrates two different methods. As your data is structured differently than the one used in the article, the XQuery to use for the XMLXQueryExtractor method would look something like this:

declare default element namespace "http://www.w3.org/1999/xhtml";
 
for $x at $n in /html/body/table/tr;1]/th
return fme:set-attribute($x/text(),/html/body/table/trb2]/tde$n]/data())

However, some features contain an HTML table that has more than one row of data. If you want to keep all HTML table rows as a feature instead of just the first row (XQuery above), you can fragment each data row and then use a HTMLExtractor or XMLXQueryExtractor to extract the data into feature attributes. 

I have attached a workspace that demonstrates both approaches and I hope it helps.


Reply