Serialization of XML document at the client side
JSON is extremely simple to use than JavaScript; there are lot of REST services already out there that use XML. In this recipe we are going to create a simple form that will construct an XML document using the DOM API for XML.
How to do it...
Let's start:
First we create a simple HTML document:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Create XML from JavaScript objects</title> </head> <body> <output id="log"> </output>
After this we are going to include a KML document inside the text, in a real life application this will probably get loaded by AJAX, but for simplicity we will add the data directly:
<kml id="test" xmlns="http://www.opengis.net/kml/2.2"> <Document> <name>Red Pyramid</name> <description><![CDATA[]]></description> <Style id="style1"> <IconStyle> ...