1

I am currently parsing through a WMS Capabilities XML file using selectors and this works great, nice clean code solution.

However I have stumbled across an issue with IE8- (Chrome, Safari, Firefox etc all working perfectly)

$.get(capabilitiesUrl, function (data) {
  $("WMT_MS_Capabilities Capability Layer Layer Name",  $(data)).not("Style Name").each(function (i) {
    layerNames[i] = $(this).text();
  });
});

This will successfully populate my array of layerNames in the decent browsers.

In IE9+ data is type of [Object, Document]

However in IE8- the type of data is a type of IXMLDOMDocument2 which I can't parse with the selector query.

The IXMLDOMDocument2 is also read only causing sizzle to throw an exception on:

outerCache = elem[ expando ] || (elem[ expando ] = {});

as it will try to run through elem[ expando ] = {} which fails as the IXMLDOMDocument2 is read only. With a Object doesn't support this property or method error.


Is there a way for me to populate my layerNames array using selectors or am I chasing the impossible?

Sphvn
  • 5,247
  • 8
  • 39
  • 57
  • This is starnge... If you comment out your current code inside the success callback and add `console.log($(data).find("WMT_MS_Capabilities"))`, do you still get an error? – darshanags Mar 11 '13 at 02:25
  • No it doesn't cause an error with just `$(data).find("WMT_MS_Capabilities")` I believe it is the `.not()` causing the error to throw in sizzle. – Sphvn Mar 11 '13 at 03:11
  • Well doing a `$(data).find("WMT_MS_Capabilities Capability Layer Layer Name").each(..` works in IE8. However if I add the `.not("Style Name")` IE8- will throw the sizzle issue as I expected. – Sphvn Mar 11 '13 at 03:15
  • can you possibly post your XML? and what is the version of jQuery you use? – darshanags Mar 11 '13 at 03:39
  • Found the solution to this but `jQuery v1.9.1` and an XML is just a WMS Capabilities that is written to spec, bit too large to share easily. – Sphvn Mar 11 '13 at 03:43

1 Answers1

1

Figured this one out.

If you use the .find() instead of the find in method it will parse properly in IE8-

Then I still had the issue of the .not() causing the exception in sizzle.

I solved this by instead of using the jQuery API of .not() to using the :not() selector.


The solution is as follows:

$(data).find("WMT_MS_Capabilities Capability Layer Layer Name:not(Style Name)").each(function (i) {
  layerNames[i] = $(this).text();
});
Sphvn
  • 5,247
  • 8
  • 39
  • 57
  • excellent! great work in finding a solution. Sorry, I had to step out - it's work time here - Monday morning. :) – darshanags Mar 11 '13 at 03:45
  • also, are you able to accept this answer and close the question? this will definitely benefit other users. – darshanags Mar 11 '13 at 03:54