Question

This is a fairly simple problem but I can't find a solution. I write some xml to a hidden div on tha page and i read it later on. The problem is that some quotes are being removed when writing to the div and because of this I can't load the use the xml in IE using LoadXML

this is the XML

<parameters id='XXX'>
<product_id value='YYY'/>
<report_id value='ZZZ'/>
<list>
    <filter_id value='AAA'/>
</list>
<date_begin value='BBB'/>
<date_end value='CCC'/>
<timeframe_id value='DDD'/>
<chart_id value='EEE'/>

I have used alot of different methods but none seem to work, I am trying to use JQUERY as much as possible to prevent cross browser issues, but any solution will do.

I append the xml, in a string variable paramString, above using

var parametersDiv = "<div id='" + reportDivId + "_params' style='visibility: hidden; display: none'>" + paramString + "</div>";

and it goes in fine.

however when I try to retrieve it the quotes around the XXX are removed in IE. Thus I can't load it using loadXML(). I could hack a solution but i'd like to do it correctly.

Any solutions would be helpful, i've wasted nearly a day on this already.

Thanks

JD

Was it helpful?

Solution

Try using double quotes and see if that does the job.

If not, another solution to your problem might be to get the XML trough a XMLHttpRequest (Ajax).

jQuery.ajax({
  url: 'yourUrlThatReturnsXML',
  dataType: 'xml',
  success: function (data, textStatus) {
   $(data); // Your XML
  }
});

OTHER TIPS

How are you inserting these hidden divs into the page? Presumably you are using innerHTML (given that you have a string), but this means that it is being passed through IE's HTML parser. This will turn it into (invalid) HTML, and when you try to retrieve it you will see the effect you describe of attributes being unquoted (and probably other side effects which you happen not to have encountered... yet).

Your best bet is to save a reference to the returned XML document (not a string serialisation thereof) in a variable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top