Search code examples
javascriptdomxml-serializationkmlgoogle-earth

Javascript XMLSerializer case sensitive


I'm generating a KML document in Javascript and i'm trying to use XMLSerializer to generate the XML file but it's generating all lower case tags even though i create the tags in capital in the DOM.

Is it the DOM that mangles the capitalization or the XMLSerializer? Is there any way to get around it or am I missing something? I've tried this in both Chrome and Firefox.

The KML document is to be imported into Google Earth and it seems it doesn't accept lower case tags.


Solution

  • Based on testing in FF4, the following will work:

    1. Use document.createElementNS ("http://www.opengis.net/kml/2.2", elementName) instead of document.createElement(elementName).

    2. Use elt.appendChild (document.createTextNode (text)) instead of elt.innerHTML = text.