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 Coder
    Join Date
    Nov 2004
    Posts
    91
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Importing XML into an XHTML document

    Ok, so here is my probelm. I am attempting to create a website that uses XHTML, and I would like to import my contents onto every page of the website from its own XML or XHTML file, how do I go about doing that? I have some JavaScript code I got out of a book but I don't understand it. And it does not work.

    <script language="JScript" type="text/javascript">
    try {
    var objXMLDOM = new ActiveXObject("Msxm12.DOMDocument.3.0");
    objXMLDOM.load("contents.xml");
    }
    catch (e)
    {
    document.write("An exception was raised.");
    }
    </script>
    So I figured I would post this here, because there must be a JavaScript way to do this that works!

    Thanks!

    Smesh

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well, using JS is not the right way to go about this, for a start, since what happens if users don't have JS installed or enabled - nothing, because they can't use your site. best way is to transform your XML serverside, then it will work in all browsers. the code you've got is Win-IE only anyway.
    *keep it simple (TM)


  •  

    Posting Permissions

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