DOMDocument('1.0', 'UTF-8') not working when using google maps
I am trying to make a map marker using this demo link
http://code.google.com/apis/kml/articles/phpmysqlkml.html
but, i get fatal error here on the line
$dom = new DOMDocument('1.0', 'UTF-8'); // Creates the root KML element and appends it to the r开发者_如何学JAVAoot document.
$node = $dom->createElementNS('http://earth.google.com/kml/2.1', 'kml');
$parNode = $dom->appendChild($node);
The script doesn't seems to work when i use NS, it tries to save the document and when i remove NS, i get the error as
**( ! ) Fatal error: Uncaught exception 'DOMException' with message 'Invalid Character Error' in C:\wamp\www\googlemap\phpsql_genkml.php on line 33 ( ! ) DOMException: Invalid Character Error in C:\wamp\www\googlemap\phpsql_genkml.php on line 33 Call Stack
Time Memory Function Location
1 0.0012 412392 {main}( ) ..\phpsql_genkml.php:0 2 0.0066 422136 DOMDocument->createElement( ) ..\phpsql_genkml.php:33**
You cannot remove the NS in createElementNS. When you do it createElement tries to create an element with the tagName "http://earth.google.com/kml/2.1"(I think I don't need to explain what invalid characters are there). The tagtName has to be kml
How do you use this generated KML in Google-Maps, who tries to save anything?
精彩评论