Skip to main content
Solved

Extracting attributes from HTML within KML with photos

  • November 16, 2021
  • 3 replies
  • 49 views

mapper
Contributor
Forum|alt.badge.img+2

Hello

I am having trouble extracting attributes from a kml for the features that have photos.

I am using XQuery similar to this example https://community.safe.com/s/question/0D54Q0000848CTkSAM/extracting-information-from-different-folders-in-kml-to-convert-to-the-shapefile

 

That method works for the features that don't have photos but the features that have photos seem to have a extra section in the HTML that is causing my XQuery to fail.

 

The Xquery I am using is :

 

declare default element namespace "http://www.w3.org/1999/xhtml";

for $x in /html/body/table/tr/td/table/tr

return fme:set-attribute($x/td[1]/text(),$x/td[2]/text())

 

I am pretty sure I just need to modify the Xquery

 

Best answer by ebygomm

If you just want to ignore the parts with a link you could do something like this

declare default element namespace "http://www.w3.org/1999/xhtml";
 
let $values :=  /html/body/table/tr/td/table/tr
 
for $v in $values
let $attrname:= $v/td[1][not(a)]
let $attrval:=$v/td[2]/text()
return fme:set-attribute($attrname,$attrval)

 

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

danilo_fme
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • 2077 replies
  • November 17, 2021

Hi @mapper​ 

 

Please, could you share a same data example?

 

 

Thanks in Advance,

Danilo


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • Best Answer
  • November 17, 2021

If you just want to ignore the parts with a link you could do something like this

declare default element namespace "http://www.w3.org/1999/xhtml";
 
let $values :=  /html/body/table/tr/td/table/tr
 
for $v in $values
let $attrname:= $v/td[1][not(a)]
let $attrval:=$v/td[2]/text()
return fme:set-attribute($attrname,$attrval)

 

 


mapper
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • 22 replies
  • November 17, 2021

If you just want to ignore the parts with a link you could do something like this

declare default element namespace "http://www.w3.org/1999/xhtml";
 
let $values :=  /html/body/table/tr/td/table/tr
 
for $v in $values
let $attrname:= $v/td[1][not(a)]
let $attrval:=$v/td[2]/text()
return fme:set-attribute($attrname,$attrval)

 

 

This worked perfectly! Thank you!