Connecting Tech Pros Worldwide Forums | Help | Site Map

XMLDoc IE removes quotes - HELP

SJ
Guest
 
Posts: n/a
#1: Mar 7 '07
Dear Friends,

I am writing an ajax app and I use an XML doc to cache a view.

For example,

Before switching to another view, i do

cache = getXMLDoc(document.getElementById("source").innerH TML);

getXMLDoc just creates a XML object and calls the loadXML method.

Then later when I switch back, I just load do a

document.getElementById("source").innerHTML = cache.xml

The problem is that sometime IE will strip the quotes off the
innerHTML and cause the loading to fail.

For example, if do:

document.getElementById("source").innerHTML = "<table
class='myClass'></table>";

when I get that value
(alert(document.getElementById("source").innerHTML ) it shows as:

<table class=myClass></table>

Then when I try to do a loadXML it fails becuase it expects a qoute.
Anyone know how to get around this?

Thanks,
-SJ


Martin Honnen
Guest
 
Posts: n/a
#2: Mar 8 '07

re: XMLDoc IE removes quotes - HELP


SJ wrote:
Quote:
The problem is that sometime IE will strip the quotes off the
innerHTML and cause the loading to fail.
>
For example, if do:
>
document.getElementById("source").innerHTML = "<table
class='myClass'></table>";
>
when I get that value
(alert(document.getElementById("source").innerHTML ) it shows as:
>
<table class=myClass></table>
The property is called innerHTML, not innerXML, and IE serializes
according to text/html HTML rules and not according to XML rules. With
HTML it is allowed, for an attribute value like myClass to omit the
quotes. So don't use innerHTML if you want XML, you will need to write
your own serializer if you want to serialize the IE HTML DOM as XML.

--

Martin Honnen
http://JavaScript.FAQTs.com/
SJ
Guest
 
Posts: n/a
#3: Mar 8 '07

re: XMLDoc IE removes quotes - HELP


On Mar 8, 6:51 am, Martin Honnen <mahotr...@yahoo.dewrote:
Quote:
SJ wrote:
Quote:
The problem is that sometime IE will strip the quotes off the
innerHTML and cause the loading to fail.
>
Quote:
For example, if do:
>
Quote:
document.getElementById("source").innerHTML = "<table
class='myClass'></table>";
>
Quote:
when I get that value
(alert(document.getElementById("source").innerHTML ) it shows as:
>
Quote:
<table class=myClass></table>
>
The property is called innerHTML, not innerXML, and IE serializes
according to text/html HTML rules and not according to XML rules. With
HTML it is allowed, for an attribute value like myClass to omit the
quotes. So don't use innerHTML if you want XML, you will need to write
your own serializer if you want to serialize the IE HTML DOM as XML.
>
--
>
Martin Honnen
http://JavaScript.FAQTs.com/
thanks for the reply. I will try that.

Closed Thread


Similar JavaScript / Ajax / DHTML bytes