XMLDoc IE removes quotes - HELP

S

SJ

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").innerHTML);

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
 
M

Martin Honnen

SJ said:
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.
 
S

SJ

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.

thanks for the reply. I will try that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top