Generate XML by Javascript in IE

D

Dario de Judicibus

I am trying to generate an XML file to be shown in IE by javascript. My code
looks like


top.x = window.open('','MyXML') ;
top.x.document.write('<?xml version="1.0" encoding="ISO-8859-1" ?>') ;
top.x.document.write('<myxml>') ;
// all the other write's
top.x.document.write('</myxml>') ;

I expected to see it ans I see any XML file in IE ( tree view ), but I don't

Why?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dr. Dario de Judicibus
http://www.dejudicibus.it/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
J

Jeff North

| I am trying to generate an XML file to be shown in IE by javascript. My code
| looks like
|
|
| top.x = window.open('','MyXML') ;
| top.x.document.write('<?xml version="1.0" encoding="ISO-8859-1" ?>') ;
| top.x.document.write('<myxml>') ;
| // all the other write's
| top.x.document.write('</myxml>') ;
|
| I expected to see it ans I see any XML file in IE ( tree view ), but I don't
|
| Why?

maybe:
top.x.document.close();

Just guessing.
 
M

Martin Honnen

Dario said:
I am trying to generate an XML file to be shown in IE by javascript. My code
looks like


top.x = window.open('','MyXML') ;
top.x.document.write('<?xml version="1.0" encoding="ISO-8859-1" ?>') ;
top.x.document.write('<myxml>') ;
// all the other write's
top.x.document.write('</myxml>') ;

I expected to see it ans I see any XML file in IE ( tree view ), but I don't

Well first of all you would have to specify the MIME type e.g.
top.x.document.open('text/xml')
before you write to the document but IE only supports document.writing
text/plain and text/html so you cannot do client-side generation of XML
that way, you need to generate the XML on the server.
 
D

Dario de Judicibus

Martin said:
Dario de Judicibus wrote:
.....
Well first of all you would have to specify the MIME type e.g.
top.x.document.open('text/xml')
before you write to the document but IE only supports document.writing
text/plain and text/html so you cannot do client-side generation of
XML that way, you need to generate the XML on the server.

So, THAT is the problem... IE! I cannot generate XML on server. I need to do
it on client side... But how?

DdJ
 
M

Martin Honnen

Dario said:
So, THAT is the problem... IE! I cannot generate XML on server. I need to do
it on client side... But how?

In IE5/6/Win you can certainly create an XML document the following way


var xmlDocument = new ActiveXObject('Microsoft.XMLDOM');
xmlDocument.async = false;

var wellFormed = xmlDocument.loadXML('<gods><god>Kibo</god></gods>');

if (wellFormed) {
alert(xmlDocument.xml);
}

however that doesn't give you a collapsible tree display in a window.

You might be able to achieve that using the stylesheet given at
http://www.dpawson.co.uk/xsl/sect2/microsoft.html#d6298e227
and run the transformation with script.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,148
Messages
2,570,838
Members
47,385
Latest member
Joneswilliam01

Latest Threads

Top