GetElementsByTagName problem in chrome and safari

I am parsing Google RSS maps using javascript and using the following code to get the coordinates of a point:

point_coords = items.getElementsByTagName ('georss: point')

Unfortunately, it works in FF, but not in safari and chrome (still not tested in Opera and IE)

XML looks like this:

<item> <guid isPermaLink="false">guidNo</guid> <pubDate>Mon, 23 Mar 2009 20:16:41 +0000</pubDate> <title>title text</title> <description><![CDATA[text]]></description> <author>UniCreditBulbank</author> <georss:point> 42.732342 23.296659 </georss:point> </item> 
+4
source share
4 answers

Ultimate solution working in IE6,7,8, FF, Opera, Chrome and Safari

 point_coords = item.getElementsByTagName('georss:point')[0]; if(!point_coords || point_coords == null){ point_coords = item.getElementsByTagName('point')[0]; } if(!point_coords || point_coords == null){ point_coords = item.getElementsByTagNameNS('http://www.georss.org/georss', 'point')[0]; } return point_coords 

Thank you for all the hints they followed)

+6
source

A similar problem for me. getElementsByTagName failed on safari, but not Firefox / Internet Exlporer. It turns out that the namespace prefix was necessary for Firefox / Internet Explorer, and not for Safari, so now, according to the agent ...

 getElementsByTagName("iesr:Collection") // ff/ie getElementsByTagName("Collection") // safari 
+3
source

Technically, the tag name for <georss:point> is equal to point , not georss:point . Try it.

+1
source

Source: https://habr.com/ru/post/948775/


All Articles