default xml namespace = new Namespace("http://www.opengis.net/kml/2.2");
Monday, March 2, 2009
Parsing KML with ActionScript XML e4x
I spent some time trying to figure out why I could not get the ActionScript XML object to properly parse a KML file and found out that the problem was in the namespace of the KML. KML sets its global namespace to whichever version of KML
you are using. The problem is that when you try to access the tags using the e4x methods it does not work. So to fix the problem you need to then set the default namespace.
Subscribe to:
Post Comments (Atom)
It is important to note that you must use the namespace mentioned in the xmlns declared in the KML that you are trying to parse.
ReplyDeleteThanks for the tip, this saved me hours of debugging!
~jookyone
THANK YOU!!
ReplyDeleteI couldn't figure out why my KML parsing wasn't working. I spent a whole day debugging until I found your site.
Wow. A full 4 years after you posted this, it's still rescuing people like me who couldn't understand why their KML parse was failing.
ReplyDeleteThanks so much!