Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DivTest.innerHTML not XHTML!
Message
Information générale
Forum:
Internet
Catégorie:
Javascript
Titre:
DivTest.innerHTML not XHTML!
Divers
Thread ID:
01006556
Message ID:
01006556
Vues:
69
Hello UT,

I just discovered that the innerHTML attribute on DHTML elements doesn't return a XHTML string.

For example, if I do (javascript) :
  divTest.innerHTML = '<div id="divMyDiv" MyCustomAttribute="hello">';

  alert(divTest.innerHTML);
it's going to show me :
<div id=divMyDiv MyCustomAttribute="hello">
notice that my id attribute is not XHTML because the quotes are missing.

I understand that it is a bug in IE... or maybe it's by design... whatever.



here's my problem :

In my code, I want to use the innerHTML of a DIV and process it using XSLT... however, since it's not XHTML, I cannot load the string in a microsoft.xmldom.

So I would like to compensate for this bug by adding the quotes to the id attributes programmatically before loading it in a microsoft.xmldom.

I would like to do it using a Regular Expression but I don't know where to start.

Basically I would like to start from
<div id=divMyDiv MyCustomAttribute="hello">
and end up with
<div id="divMyDiv" MyCustomAttribute="hello">
Does anybody have any hint or a Regular Expression that does that?
Any help will be appreciated.

Thank you,
Alex
Alexandre Boudreault-Ferland
Chief Technology Officer
AZUR Technologies
http://www.xicommunity.ca
http://www.xiazur.com
http://endfunction.blogspot.com
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform