SPXMLtoJSON

Sep 22, 2014 at 5:47 AM
Seem to be having an issue with browser compatibility with the SPXMLtoJSON function.

I always use the JSON return, so I'm quite comfortable with it and the code was used from an existing copy/paste.

Here's what I'm experiencing:

If the result set has more than a handful of records, the object returned is empty. If it only has a few then the return is a valid object.

Here's what I've done so far:

Verified that the responseXML PRIOR to the SPXMLtoJSON call is valid. Checked the returned object AFTER the SPXMLtoJSON call and it is empty (when the results are more than a few).

Now, here's the kicker --- this particular function had been working, both on small and large result sets. I do have a client who has been getting in the way and messing with my code, but even when going back to a version that was prior to the client making any changes (not sure if they were to this particular function, he says not) it is still not working on large returns.

What I discovered tonight:
I can run the function in Chrome and it will return the results as expected (with slight hiccup of the object being formatted incorrectly, but still returning the proper amount of rows. However, in IE8, it is returning an empty object.

I know the SPXML works in IE8, so what could it be?

One thing I have been pondering, and I have yet to test, is that the list being pulled is a Document Set and I'm wondering if the presence of a file in the library is causing the return in IE to be different somehow?

What are your thoughts?

I'm going to dig this around a few and see if I can find a resolution as this was originally listed as a tested feature and set for release this week, so getting it up will be key.

Any help you can provide would be much appreciated.

/Anthony
Coordinator
Sep 22, 2014 at 1:01 PM
Anthony:

I've been using SPXmlToJson extensively with IE8 for a long time now, so I don't think that in itself is the issue.

I'd check for an error in the console and see what's causing it. It's certainly possible that there's some edge case that I'm missing in the code. Do you have any custom field types? If you do, that could cause a problem.

M.
Sep 22, 2014 at 6:12 PM
sympmarc wrote:
Anthony:

I've been using SPXmlToJson extensively with IE8 for a long time now, so I don't think that in itself is the issue.

I'd check for an error in the console and see what's causing it. It's certainly possible that there's some edge case that I'm missing in the code. Do you have any custom field types? If you do, that could cause a problem.

M.
Same here in terms of extensive use with IE8, which is why this is so baffling. It was just a simple copy/paste that was originally working, now failing. I even went back and re-did the copy/paste creation and it is still having an issue.

So here is what I discovered today. responseText has the value it should (string of xml), however, responseXML is not simply empty but it isn't created by the call to SPServices in the xData object at all.

Any thoughts? Found a few discussions stating similar issue with a previously working function and responseXML being empty but no conclusive answer as to why and how to resolve.

/Anthony
Sep 23, 2014 at 3:58 AM
I seem remember a post here on the same issue ( responseXML is not set). Don't recall what the root cause was though. That attribute, I think is either set by the XMLHTTPREQUEST class or by jQuery content type parser.
This issue has a work-around to using the responseTEXT: http://spservices.codeplex.com/workitem/10186


Can you post your code to GetListItems and also, re-check the versions of jQuery and SPServices being used (I suggest a breakpoint before the SPServices call or an alert).

Also, do you know whether jQuery's global ajax methods are being used to manipulate the request? Say perhaps: setting contentType to text?





--
Paul T.

-- Sent from Mobile

Sep 23, 2014 at 8:47 PM
First thing I tried was to parse the responseText into XML, but it fails due to malformed XML.

Here's the code that I have for the GetListItems:
$().SPServices({
            operation: "GetListItems", 
            listName: 'XXX',
            CAMLViewFields: "<ViewFields Properties='True' />",
            CAMLQuery: "<Query><Where>" + fltr + "</Where></Query>",
            completefunc: function (xData, Status) {

/// Here if you check xData, it does not have responseXML IF USING IE. Running the same code in Chrome will result in the responseXML being created without issue.
Additional information:
  • fltr is passed from your (Paul) SPFilterPanel and I have verified that it is populated properly.
  • code works in Chrome
  • The filter panel has 2 fields (Title and a people picker field)
  • issue only comes up when more than a handful of results are to be expected.
  • if I have 2 or 3 results returned, then there is no issue.
  • if I use the people picker on someone who will have many results then responseXML is not created, but responseText is successful but with malformed XML when attempting to parse. Could this be the issue? Could it be attempting to create the XML object and failing? Why?
Sep 23, 2014 at 10:01 PM
OK, so here is the next update.

It is definitely a parser error related to the values in the items returned. If I dig down deeper into the responseText, the XML formatting breaks part way through.

Looking through options now.
Coordinator
Sep 23, 2014 at 10:03 PM
I've found that in some instances, breaking on the code in the debugger breaks the XML. It makes no sense, but there you go.

If the code worked before and now doesn't, focus on what changed, not the code itself.

M.
Sep 23, 2014 at 10:35 PM
Here is the EXACT same parsing issue I am having trouble with - https://spservices.codeplex.com/discussions/248939

Doesn't seem like that item ever had a resolution. Changed my ViewFields to just the 2 that I need, but as stated in the link referenced above, it still returns all fields, which then brings in the field with the character causing the issue.
Sep 24, 2014 at 12:40 AM
How much data you pulling back with the filter? thousands of records? Could this be an issue where IE8 chokes trying to parse large XML text string?

Are you saying that doing a $.parseXML(xData.responseText), fails?


_________
Paul T

Sep 24, 2014 at 3:16 AM
ptavares wrote:
How much data you pulling back with the filter? thousands of records? Could this be an issue where IE8 chokes trying to parse large XML text string? Are you saying that doing a $.parseXML(xData.responseText), fails? _________ Paul T
The test this is being run on should only return 20ish records. The problem is that it appears there are some values in some of the fields that are throwing off the XML encoding, which causes responseXML to not be established.

If I try $.parseXML(...) it fails due to malformed XML.

I'm trying to figure out which characters are causing the issue and then I'll work in some encoding prior to utilizing parseXML().

For now, I'm going to have to go ahead and utilize the panel and pass the values via query string and do some filtering as this particular piece is the single remaining item that I need to close out before pushing to production.

I'll update on this as soon as I find out which characters are causing the issue.

/Anthony