innerHTML Alternative in Firefox
The problem, while it appends the information to the element, only the text is appended and none of the HTML is parsed, resulting in just a concatonated string. For some reason, the browser ignores any of the markup.
This seems to be the case in both the DOM compliant browsers I have tested the code in (Firefox and Netscape). So I am thinking that this is a feature of the DOM API rather than a bug. If indeed this, is the case, how do I get the DOM to recognise the XML I am appending as XHTML.
Below is the Javascript I am using to append the HTML fragment.
var transformed = '';
var oXml = loadXmlFromString(xmlHTTP.responseText);
if (window.ActiveXObject) { // Internet Explorer
bookSummary.innerHTML = oXml.xml;
} else if (oXml.documentElement){ // w3c compliant browsers
if (bookSummary.firstChild) {
bookSummary.replaceChild(oXml.documentElement,bookSummary.firstChild);
} else {
bookSummary.appendChild(oXml.documentElement);
}
}
function loadXmlFromString(sXml)
{
var oXml = getXML();
if (window.ActiveXObject) { // Internet Explorer
oXml.loadXML(sXml);
return oXml;
} else if ((typeof DOMParser) != "undefined") { // w3c Compliant Browsers
var parser = new DOMParser();
var ret = parser.parseFromString(sXml, 'text/xml');
return ret;
}
throw 'Cannot load XMl from string';
}
function getXML()
{
return document.implementation.createDocument('', '', null);
}

