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.
The following works for me (preserving case) in FF 5 beta in an XHTML page:
It doesn't matter if you add elements with capital letters, the DOM manages them always in lower case. Just check it with firebug, you won't see uppercase tags.
In case your doctype is set to XHTML it even breaks standard compliance.
UPDATE: just checked following:
So already when you create the element, it's being parsed and converted to lowercase.
Based on testing in FF4, the following will work:
Use
document.createElementNS ("http://www.opengis.net/kml/2.2", elementName)
instead ofdocument.createElement(elementName)
.Use
elt.appendChild (document.createTextNode (text))
instead ofelt.innerHTML = text
.