www.webdeveloper.com
Results 1 to 4 of 4

Thread: XML and DHTML

  1. #1
    Join Date
    Sep 2003
    Location
    Australia
    Posts
    37

    Question XML and DHTML

    Hi,

    How do i Dynamically write an XML document into IE using script?

    I get Plain Text in XML format from a web request, which I am trying to display in Tree or "Pretty Print" format. but the document.write treats it as plain txt, inspite of my first tag being <?xml .......?>.

    So how do i make thw browser window treat the text as XML??????

    Any help is much appreciated..

    - Paps

  2. #2
    Join Date
    Feb 2003
    Location
    Rhode Island, United States of America
    Posts
    448
    document.write("")
    should work

  3. #3
    Join Date
    Sep 2003
    Location
    Australia
    Posts
    37
    it works, i.e. it prints it out, but the browser then treats it as plain text instead of XML, which means that if I put in a reference for an XSL, it wont refer to it.

    I have a way around it, i.e I myself query the XSL URL, then use the Transform Method, convert the XML to HTML and show HTML in the browser.

    Or Save the file on local Temp directory and then open the window with that URL (referring to the file on local hard disk)

    neither solution is good...first one requires you to make an extra Http Request, do the transformation and display, second one has obvious security problems.....

    so.......

  4. #4
    Join Date
    Aug 2003
    Location
    London, United Kingdom
    Posts
    117
    IMHO, you must create an xml object, everything else will treat your output file as text, not xml. Document.write will output your xml as it is... if formatted, it will be formatted,
    if not, it will be not...

    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript">
    function load()
    {
    var xmldoc=new ActiveXObject("MSXML2.DOMDocument.3.0");
    xmldoc.load("xml01.xml");
    document.write(xmldoc.documentElement.xml);
    }
    </SCRIPT>
    </head>
    <body>
    <A HREF="javascript:load()">Load XML file</A>
    </body>
    </html>
    You end up being who you are.
    http://www.geocities.com/lillamarta

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles