View Full Version : Embedding XML in HTML, reading it with Javascript?

08-20-2008, 10:13 PM
Good afternoon everyone!

I currently have a xml document separate from my html document. We read in the XML document using javascript like this:
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");

Everything works great, but we would also like a way to combine both documents together into one html file. This would make sending the .html file in an email feasable where emailing the html and the xml is not.

Is there a way to play the contents of the .xml in our html document and then somehow load it in?

I have tried xmlDoc.loadXML(some_string); where some_string was one long string but that didn't seem to work. I did put a \ at the end of every line. I tried the same thing with a real tiny simple xml document in one string and that did work. I think what breaks it is all of the CDATA sections in our xml.

Thanks for tips!

08-21-2008, 07:47 PM
Well I figured this out in case anyone else needs to know how. This article helped a lot:

I changed the new ActiveXObject to document.getElementById(), and I also had to change my readyState from "readyState == "4" to "complete".