Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Embedding XML in HTML, reading it with Javascript?

    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");
    xmlDoc.load("items.xml");

    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!

  • #2
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well I figured this out in case anyone else needs to know how. This article helped a lot:
    http://poeticcode.wordpress.com/2007...d-xml-in-html/

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •