Encoding a string in a HTTP Post

Encoding a string in a HTTP Post

Hi, I'm trying to use the Google API for adding placemarks on maps.

The HTTP body needs to have the following:

  1. <atom:entry xmlns='http://www.opengis.net/kml/2.2'
       
    xmlns:atom='http://www.w3.org/2005/Atom'>
       
    <atom:title type='text'>Faulkner's Birthplace</atom:title>
       
    <atom:content type='application/vnd.google-earth.kml+xml'>
         
    <Placemark>
           
    <name>Faulkner's Birthplace</name>
           
    <description/>
           
    <Point>
             
    <coordinates>-89.520753,34.360902,0.0</coordinates>
           
    </Point>
         
    </Placemark>
       
    </atom:content>
    </atom:entry>
However I try to insert this into a map variable to be used in the postURL function I cannot get the string to encode correctly.

So I do:




  1. xmlEncode = "<atom:entry xmlns='http://www.opengis.net/kml/2.2' xmlns:atom='http://www.w3.org/2005/Atom'> <atom:title type='text'>Robs House</atom:title> <atom:content type='application/vnd.google-earth.kml+xml'> <Placemark> <name>Rob House</name> <description/> <Point> <coordinates>" + lng + "," + lat + ",0.0</coordinates> </Point> </Placemark> </atom:content> </atom:entry>";

and then:

  1. info xmlEncode;
I get:

  1. Executed Successfully
    Log messages :
    {"XMLString":" Robs House<\/atom:title> Rob House<\/name> -0.4019501,51.4118992,0.0<\/coordinates> <\/Point> <\/Placemark> <\/atom:content> <\/atom:entry>"}


So this is not going to work when posted.

Can you advise? I have tried escaping the string in many different ways without being successful.