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??????
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.....
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
Bookmarks