sboles wrote:
[color=blue]
> My specific application: I am transforming XML data into HTML and then
> injecting it into the page's DOM. The problem I am having is that the
> class attribute is not handled as a class property. The result then is
> that the CSS style definition for the class is not applied by the
> browser. My general problem is: How to inject xmlResponse data into
> the page's DOM and preserve the class name and id properties?[/color]
If you want to have HTML elements in responseXML then you need to make
sure you send XHTML with the proper namespace e.g. instead of sending
<p class="style1">Kibology for all.</p>
make sure you send
<p xmlns="http://www.w3.org/1999/xhtml" class="style1">Kibology for
all.</p>
then when Mozilla's XML parser parses the response sent from the server
into responseXML it has (X)HTML DOM nodes in there which you can
directly import into your existing HTML DOM document e.g. if responseXML
is an XML document with the above markup then you can do
document.body.appendChild(document.importNode(resp onseXML.documentElement,
true));
No need to try to fix up any properties, that will not work, if you have
<p class="style1">...</p>
parsed by an XML parser then it doesn't create an HTMLPElement which has
a className property but simply creates an Element node with tag name
'p' and one attribute named 'class' with value 'style1' but neither the
element is treated as HTML <p> element node nor the attribute as
anything related to CSS style classes.
So use the proper namespace, then import nodes and Mozilla will do the rest.
--
Martin Honnen
http://JavaScript.FAQTs.com/