Hi Everyone,

I am trying to write a string variable containing XML in the form of text into an iframe such that it shows up as formatted XML with the expand(+) and collapse (-) options that default in IE when opening an XML file.

The first thing I tried is writing the string to a file with .xml extension and setting the iFrame src to that file. This works well normally, however in this case, the file does not get created where I want to due to some security restrictions in IE which I cannot edit as I dont have admin rights.

Secondly I tried appending the string as innerHTML to that iframe but only the content within the XML tags without any formatting shows up which is not intended.

Thirdly I cannot use any server side scripting as this is a very controlled environment and I am not allowed to host servers or edit server scripts at will. This is totally out of question, so I guess Ajax or calling a costom defined web service wont help.

At best I can say, I am limited to HTML, Javascript and vbScript.

I am receiving the string as a responseText from an ajax request which is consuming a web service. If I use responseXML, it doesn't work.

The solution I am looking at is to either display it as formatted XML in an iFrame or to just throw it into a textarea which I am already doing and simultaneously write it to an XML file or do both. If not automatically, atleast have the user press a button and do it.

I am at my wit's end.

Please help.

Thanks in advance.

Sriram

Recommended Answers

All 4 Replies

I tried something like this...

newWindow = window.open("");
newDocument = newWindow.document.open("text/xml");
newDocument.write(xmlText);
newDocument.close();

Its actually writing things in the titlebar of the new window I opened. When I do a view source... it displays the entire XML fine. Please correct me if I may have gone wrong somewhere. I want IE to use its XSL stylesheet and display the XML data.

Thanks for your help.

Some thoughts: IE really doesn't support text/xml anymore (why?). I know you said you can't use anything remote, but, as I can't think of another solution :) : you could remotely (on another server) host a server-side that just echos back some GET variable (for example <?php echo $_GET['code']; ?> ), and then set the iframe's source to view-source:http:some_server.com/that_file.php?code=the%20xml. In firefox, at least, this works. In IE and chrome you'll need to decorate the code in php and remove the view-source:.

Thanks @twiss,

Unfortunately, I have no access to setup my own or host a file on a server; not even a php one-liner :(. So I guess I will need to keep searching and figure out an out-of-the ordinary process to achieve this :). I will definitely keep the forum posted of my progress. Hopefully I will hit eureka! soon.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.