title: Adding KML to OpenLayers as a textstring
body: <p>I am trying to display a kml as a vector Layer. I have it stored as a Perl scalar variable but have also tried setting it as a javascript variable. I've tried to separate bits of code that I got from questions on here. The first one produces no error but the vector_layer doesn't display <a href="http://www.geos.ed.ac.uk/~s0825955/cgi-bin/maps4.pl" rel="nofollow">http://www.geos.ed.ac.uk/~s0825955/cgi-bin/maps4.pl</a>:  </p>
  
  <pre><code>var kml_string = '&lt;?xml version="1.0" encoding="utf-8" ?&gt;&lt;kml xmlns="http://www.opengis.net/kml/2.2"&gt;&lt;Document&gt;&lt;Folder&gt;&lt;name&gt;scotland_one_inch_1st&lt;/name&gt;&lt;Schema name="scotland_one_inch_1st" id="scotland_one_inch_1st"&gt;&lt;SimpleField name="Name" type="string"&gt;&lt;/SimpleField&gt;&lt;SimpleField name="Description" type="string"&gt;&lt;/SimpleField&gt;&lt;SimpleField name="SHEET" type="string"&gt;&lt;/SimpleField&gt;&lt;/Schema&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Linlithgowshire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Linlithgowshire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.8271,56.0204 -3.3023,56.0204 -3.3023,55.8149 -3.8271,55.8149&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Stirlingshire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Stirlingshire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.6992,56.2988 -3.6282,56.2988 -3.6282,55.8927 -4.6992,55.8927&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Berwick-Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Berwick-Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-2.9047,55.944 -2.0344,55.944 -2.0344,55.5665 -2.9047,55.5665&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Peebles-Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Peebles-Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.5401,55.8247 -2.9182,55.8247 -2.9182,55.403 -3.5401,55.403&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Kirkcudbright-Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Kirkcudbright-Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.6636,55.3226 -3.563,55.3226 -3.563,54.7662 -4.6636,54.7662&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Edinburgh Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Edinburgh Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.7407,55.9899 -2.8252,55.9899 -2.8252,55.6441 -3.7407,55.6441&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Northern Part of Lanarkshire. Southern Part....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Northern Part of Lanarkshire. Southern Part....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.3831,55.9402 -3.394,55.9402 -3.394,55.2893 -4.3831,55.2893&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Haddington....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Haddington....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.0132,56.0792 -2.364,56.0792 -2.364,55.8175 -3.0132,55.8175&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Orkney Islands....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Orkney Islands....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.4344,59.3921 -2.3736,59.3921 -2.3736,58.6868 -3.4344,58.6868&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Roxburghshire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Roxburghshire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.1198,55.7047 -2.1658,55.7047 -2.1658,55.1084 -3.1198,55.1084&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Kincardine Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Kincardine Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-2.7564,57.1307 -2.0535,57.1307 -2.0535,56.7444 -2.7564,56.7444&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Caithness Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Caithness Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.8585,58.6938 -3.024,58.6938 -3.024,58.1369 -3.8585,58.1369&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Western Isles....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Western Isles....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-7.698,58.5156 -6.1365,58.5156 -6.1365,56.7781 -7.698,56.7781&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Dumbartonshire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Dumbartonshire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.8813,56.3316 -3.8628,56.3316 -3.8628,55.8899 -4.8813,55.8899&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Buteshire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Buteshire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-5.3982,55.9269 -4.899,55.9269 -4.899,55.424 -5.3982,55.424&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Sutherland Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Sutherland Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-5.4047,58.6275 -3.5972,58.6275 -3.5972,57.8487 -5.4047,57.8487&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Northern Part of Argyll Shire. Southern Part....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Northern Part of Argyll Shire. Southern Part....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-7.1189,56.8668 -4.5622,56.8668 -4.5622,55.2767 -7.1189,55.2767&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Selkirk Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Selkirk Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.3554,55.6913 -2.763,55.6913 -2.763,55.3408 -3.3554,55.3408&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Skye Island, &amp;amp;#38;c....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Skye Island, &amp;amp;#38;c....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-6.7898,57.7461 -5.648,57.7461 -5.648,56.8242 -6.7898,56.8242&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Northern Part of Angus Shire. Southern Part....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Northern Part of Angus Shire. Southern Part....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.4065,56.9857 -2.3875,56.9857 -2.3875,56.4327 -3.4065,56.4327&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Northern Part of Ross and Cromarty Shires. Southern Part....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Northern Part of Ross and Cromarty Shires. Southern Part....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-5.8722,58.1262 -3.7721,58.1262 -3.7721,57.0951 -5.8722,57.0951&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Northern Part of Aberdeen &amp;amp;#38; Banff Shires. Southern Part....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Northern Part of Aberdeen &amp;amp;#38; Banff Shires. Southern Part....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.8016,57.7065 -1.7667,57.7065 -1.7667,56.8723 -3.8016,56.8723&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Perthshire with Clackmannan....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Perthshire with Clackmannan....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.8529,56.9484 -3.0572,56.9484 -3.0572,56.0796 -4.8529,56.0796&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, County of Wigtown or Shire of Galloway...&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, County of Wigtown or Shire of Galloway...&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-5.1864,55.0613 -4.3442,55.0613 -4.3442,54.6336 -5.1864,54.6336&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Renfrew Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Renfrew Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.8985,55.9624 -4.226,55.9624 -4.226,55.6724 -4.8985,55.6724&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Fife with Kinross Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Fife with Kinross Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.7405,56.453 -2.5472,56.453 -2.5472,56.0059 -3.7405,56.0059&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Northern Part of Ayrshire. Southern Part....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Northern Part of Ayrshire. Southern Part....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-5.1242,55.8898 -3.9608,55.8898 -3.9608,54.9976 -5.1242,54.9976&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Dumfriesshire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Dumfriesshire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.1218,55.4606 -2.857,55.4606 -2.857,54.9645 -4.1218,54.9645&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Shetland Islands....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Shetland Islands....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-2.1162,60.8545 -.7347,60.8545 -.7347,59.5132 -2.1162,59.5132&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Nairn and Elgin....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Nairn and Elgin....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.0087,57.7248 -2.9907,57.7248 -2.9907,57.2932 -4.0087,57.2932&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Northern Part of Inverness Shire. Southern Part....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Northern Part of Inverness Shire. Southern Part....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-6.0806,57.6319 -3.4317,57.6319 -3.4317,56.6859 -6.0806,56.6859&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;/Folder&gt;&lt;/Document&gt;&lt;/kml&gt;'; // you kml text stored as a javascript string
  var kmlParser = new OpenLayers.Format.KML({extractAttributes: true});
  var featurelist = kmlParser.read(kml_string);
  
  var vector_Layer = new OpenLayers.Layer.Vector(featurelist);
  </code></pre>
  
  <p>Here is a second attempt. It produces <code>Uncaught SyntaxError: Unexpected identifier</code> when I try and add controls <code>select = new OpenLayers.Control.SelectFeature(vector_Layer);</code>. <a href="http://www.geos.ed.ac.uk/~s0825955/cgi-bin/maps3.pl" rel="nofollow">http://www.geos.ed.ac.uk/~s0825955/cgi-bin/maps3.pl</a></p>
  
  <pre><code>var vector_Layer = new OpenLayers.Layer.Vector();
  
  function GetFeaturesFromKMLString (strKML) {
      var format = new OpenLayers.Format.KML({
         'internalProjection': myMapObject.baseLayer.projection,
          'externalProjection': new OpenLayers.Projection("EPSG:4326")
      });
      return format.read(strKML);
  };
  
  vector_Layer.addFeatures(GetFeaturesFromKMLString('&lt;?xml version="1.0" encoding="utf-8" ?&gt;&lt;kml xmlns="http://www.opengis.net/kml/2.2"&gt;&lt;Document&gt;&lt;Folder&gt;&lt;name&gt;scotland_one_inch_1st&lt;/name&gt;&lt;Schema name="scotland_one_inch_1st" id="scotland_one_inch_1st"&gt;&lt;SimpleField name="Name" type="string"&gt;&lt;/SimpleField&gt;&lt;SimpleField name="Description" type="string"&gt;&lt;/SimpleField&gt;&lt;SimpleField name="SHEET" type="string"&gt;&lt;/SimpleField&gt;&lt;/Schema&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Linlithgowshire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Linlithgowshire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.8271,56.0204 -3.3023,56.0204 -3.3023,55.8149 -3.8271,55.8149&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Stirlingshire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Stirlingshire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.6992,56.2988 -3.6282,56.2988 -3.6282,55.8927 -4.6992,55.8927&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Berwick-Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Berwick-Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-2.9047,55.944 -2.0344,55.944 -2.0344,55.5665 -2.9047,55.5665&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Peebles-Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Peebles-Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.5401,55.8247 -2.9182,55.8247 -2.9182,55.403 -3.5401,55.403&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Kirkcudbright-Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Kirkcudbright-Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.6636,55.3226 -3.563,55.3226 -3.563,54.7662 -4.6636,54.7662&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Edinburgh Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Edinburgh Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.7407,55.9899 -2.8252,55.9899 -2.8252,55.6441 -3.7407,55.6441&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Northern Part of Lanarkshire. Southern Part....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Northern Part of Lanarkshire. Southern Part....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.3831,55.9402 -3.394,55.9402 -3.394,55.2893 -4.3831,55.2893&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Haddington....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Haddington....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.0132,56.0792 -2.364,56.0792 -2.364,55.8175 -3.0132,55.8175&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Orkney Islands....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Orkney Islands....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.4344,59.3921 -2.3736,59.3921 -2.3736,58.6868 -3.4344,58.6868&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Roxburghshire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Roxburghshire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.1198,55.7047 -2.1658,55.7047 -2.1658,55.1084 -3.1198,55.1084&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Kincardine Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Kincardine Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-2.7564,57.1307 -2.0535,57.1307 -2.0535,56.7444 -2.7564,56.7444&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Caithness Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Caithness Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.8585,58.6938 -3.024,58.6938 -3.024,58.1369 -3.8585,58.1369&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Western Isles....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Western Isles....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-7.698,58.5156 -6.1365,58.5156 -6.1365,56.7781 -7.698,56.7781&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Dumbartonshire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Dumbartonshire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.8813,56.3316 -3.8628,56.3316 -3.8628,55.8899 -4.8813,55.8899&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Buteshire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Buteshire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-5.3982,55.9269 -4.899,55.9269 -4.899,55.424 -5.3982,55.424&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Sutherland Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Sutherland Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-5.4047,58.6275 -3.5972,58.6275 -3.5972,57.8487 -5.4047,57.8487&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Northern Part of Argyll Shire. Southern Part....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Northern Part of Argyll Shire. Southern Part....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-7.1189,56.8668 -4.5622,56.8668 -4.5622,55.2767 -7.1189,55.2767&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Selkirk Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Selkirk Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.3554,55.6913 -2.763,55.6913 -2.763,55.3408 -3.3554,55.3408&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Skye Island, &amp;amp;#38;c....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Skye Island, &amp;amp;#38;c....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-6.7898,57.7461 -5.648,57.7461 -5.648,56.8242 -6.7898,56.8242&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Northern Part of Angus Shire. Southern Part....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Northern Part of Angus Shire. Southern Part....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.4065,56.9857 -2.3875,56.9857 -2.3875,56.4327 -3.4065,56.4327&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Northern Part of Ross and Cromarty Shires. Southern Part....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Northern Part of Ross and Cromarty Shires. Southern Part....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-5.8722,58.1262 -3.7721,58.1262 -3.7721,57.0951 -5.8722,57.0951&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Northern Part of Aberdeen &amp;amp;#38; Banff Shires. Southern Part....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Northern Part of Aberdeen &amp;amp;#38; Banff Shires. Southern Part....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.8016,57.7065 -1.7667,57.7065 -1.7667,56.8723 -3.8016,56.8723&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Perthshire with Clackmannan....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Perthshire with Clackmannan....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.8529,56.9484 -3.0572,56.9484 -3.0572,56.0796 -4.8529,56.0796&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, County of Wigtown or Shire of Galloway...&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, County of Wigtown or Shire of Galloway...&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-5.1864,55.0613 -4.3442,55.0613 -4.3442,54.6336 -5.1864,54.6336&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Renfrew Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Renfrew Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.8985,55.9624 -4.226,55.9624 -4.226,55.6724 -4.8985,55.6724&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Fife with Kinross Shire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Fife with Kinross Shire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-3.7405,56.453 -2.5472,56.453 -2.5472,56.0059 -3.7405,56.0059&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Northern Part of Ayrshire. Southern Part....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Northern Part of Ayrshire. Southern Part....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-5.1242,55.8898 -3.9608,55.8898 -3.9608,54.9976 -5.1242,54.9976&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Dumfriesshire....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Dumfriesshire....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.1218,55.4606 -2.857,55.4606 -2.857,54.9645 -4.1218,54.9645&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Shetland Islands....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Shetland Islands....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-2.1162,60.8545 -.7347,60.8545 -.7347,59.5132 -2.1162,59.5132&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Nairn and Elgin....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Nairn and Elgin....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-4.0087,57.7248 -2.9907,57.7248 -2.9907,57.2932 -4.0087,57.2932&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;Placemark&gt;&lt;name&gt;John Thomson, Northern Part of Inverness Shire. Southern Part....&lt;/name&gt;&lt;ExtendedData&gt;&lt;SchemaData schemaUrl="scotland_one_inch_1st"&gt;&lt;SimpleData name="SHEET"&gt;John Thomson, Northern Part of Inverness Shire. Southern Part....&lt;/SimpleData&gt;&lt;/SchemaData&gt;&lt;/ExtendedData&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-6.0806,57.6319 -3.4317,57.6319 -3.4317,56.6859 -6.0806,56.6859&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;&lt;/Placemark&gt;&lt;/Folder&gt;&lt;/Document&gt;&lt;/kml&gt;'))
  </code></pre>
  
  <p>I thought It should have a semicolon at the end but it spat that out.</p>
  
  <p>So what I want to ask is which technique would you recommend I persevere with and what do I need to fix?</p>
  
  <p>EDIT: having added the missing bracket the second answer now produces the same error-free but blank response</p>