-1

i am trying to parse my kml file which contains the data with degree symbol and IE cannot recognize that symbol. So i need to either replace the degree symbol with its hash code or have to escape this character. i have verified a lot of links but non of them worked for me.`

geoXML3.fetchXML = function (url, callback) {
  function timeoutHandler() {
    geoXML3.log('XHR timeout');
    callback();
  };

  var xhrFetcher = new Object();
  if (!!geoXML3.fetchers.length) {
    xhrFetcher = geoXML3.fetchers.pop();
  } else {
    if (!!window.XMLHttpRequest) {
      xhrFetcher.fetcher = new window.XMLHttpRequest(); // Most browsers
    } else if (!!window.ActiveXObject) {
      xhrFetcher.fetcher = new window.ActiveXObject('Microsoft.XMLHTTP'); // Some IE
    }
  }

  if (!xhrFetcher.fetcher) {
    geoXML3.log('Unable to create XHR object');
    callback(null);
  } else {
      xhrFetcher.fetcher.open('GET', url, true);
      if (xhrFetcher.fetcher.overrideMimeType) {
        xhrFetcher.fetcher.overrideMimeType('text/xml');
      }
      xhrFetcher.fetcher.onreadystatechange = function () {
      if (xhrFetcher.fetcher.readyState === 4) {
        // Retrieval complete
        if (!!xhrFetcher.xhrtimeout)
          clearTimeout(xhrFetcher.xhrtimeout);
        if (xhrFetcher.fetcher.status >= 400) {
          geoXML3.log('HTTP error ' + xhrFetcher.fetcher.status + ' retrieving ' + url);
          callback();
        } else {
          // Returned successfully
          var xml = geoXML3.xmlParse(xhrFetcher.fetcher.responseText);
          if (xml.parseError && (xml.parseError.errorCode != 0)) {
           geoXML3.log("XML parse error "+xml.parseError.errorCode+", "+xml.parseError.reason+"\nLine:"+xml.parseError.line+", Position:"+xml.parseError.linepos+", srcText:"+xml.parseError.srcText);
           xml = "failed parse"
          } else if (geoXML3.isParseError(xml)) {
           geoXML3.log("XML parse error");
           xml = "failed parse"
          }
          callback(xml);
        }
        // We're done with this fetcher object
        geoXML3.fetchers.push(xhrFetcher);
      }
    };
    xhrFetcher.xhrtimeout = setTimeout(timeoutHandler, geoXML3.xhrTimeout);
    xhrFetcher.fetcher.send(null);
  }
};

this is the code which i am using to parse my kml file. this work fine in other browser but not in IE

essitco java1
  • 35
  • 1
  • 5
  • What does the KML look like? – geocodezip Sep 21 '15 at 14:37
  • What character encoding is your KML file using? – geocodezip Sep 21 '15 at 23:13
  • my kml file has utf-8 character encoding, but stiil when the geoxaml parser parses it, it always generate error in case of IE only – essitco java1 Sep 22 '15 at 06:24
  • What does your KML file look like? It works for me when it is UTF-8 encoded. – geocodezip Sep 22 '15 at 06:27
  • sorry i am unable to understand you what you are asking "KML file look like" what ???? – essitco java1 Sep 22 '15 at 06:33
  • Please post the contents of an example KML file that exhibits this issue in your question (a link to a KML file that exhibits the problem would be useful as well, but you should provide a [Minimal, Complete, Tested and Readable example](http://stackoverflow.com/help/mcve) that exhibits the issue **in the question itself**). – geocodezip Sep 22 '15 at 12:54
  • `Chemical Name: HYDROGEN SULFIDE
    Wind: 0.8 meters/second from 180.0° true at 3 meters
    ` This is the code which makes the problem while parsing my kml file
    – essitco java1 Sep 23 '15 at 10:37

1 Answers1

0

Your KML is invalid.

<description><b>Chemical Name:</b> HYDROGEN SULFIDE<br><b>Wind:</b> 0.8 meters/second from 180.0° true at 3 meters<br></description>

This works for me:

<description><b>Chemical Name:</b> HYDROGEN SULFIDE<br /><b>Wind:</b> 0.8 meters/second from 180.0° true at 3 meters<br /></description>

http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.html?filename=http://www.geocodezip.com/geoxml3_test/kml/629262-nmea2.kml

geocodezip
  • 158,664
  • 13
  • 220
  • 245
  • sir i appreciate your efforts, but could you please explain me whats the difference between the above two lines – essitco java1 Sep 24 '15 at 09:33
  • The first is not valid XML. The second is (a `
    ` tag needs to be closed with a `` tag in XML or written `
    `)
    – geocodezip Sep 24 '15 at 13:46
  • sir could you please suggest what should i do in case when kml is auto generated by a software not manually coded, which is the case with me. – essitco java1 Sep 25 '15 at 04:15
  • And also i converted
    to
    manually and then tried to parse it still same error no change in the error in console of IE
    – essitco java1 Sep 25 '15 at 04:30
  • It works for me. Please provide a [Minimal, Complete, Tested and Readable example](http://stackoverflow.com/help/mcve) that exhibits the issue (or at least a complete KML file that does). – geocodezip Sep 25 '15 at 05:12
  • i don't know how to upload my kml file here other wise the no of characters are too much that they exceed the limit – essitco java1 Sep 25 '15 at 05:18
  • Either provide a link to your KML or compare yours to my working example and figure out what the difference is (although I would think you would be able to put together a simple KML file that exhibits the problem that would fit in the character limits of your question. You can certainly remove the snippet from geoxml3, that isn't the issue. – geocodezip Sep 25 '15 at 05:23
  • could you please tell me what geo code you are using to parse your kml file – essitco java1 Sep 25 '15 at 05:36
  • It is in the link provided. – geocodezip Sep 25 '15 at 14:20
  • sorry for replying after long time but this code still doesn't work for me – essitco java1 Oct 02 '15 at 06:07
  • Please provide a [Minimal, Complete, Tested and Readable example](http://stackoverflow.com/help/mcve) that exhibits the issue (or at least a complete KML file that does). – geocodezip Oct 02 '15 at 06:09
  • sir please provide me your email so that i can send you my kml file and you may check that kml file – essitco java1 Oct 02 '15 at 06:34
  • Please add a [Minimal, Complete, Tested and Readable example](http://stackoverflow.com/help/mcve) of your KML to your question. – geocodezip Oct 02 '15 at 12:49
  • its amazing to tell that i have resolved my proble by just escaping the special characters before parsing my kml file – essitco java1 Oct 05 '15 at 04:04