Click to See Complete Forum and Search --> : display xml in new window


gkoenig
04-01-2003, 04:03 AM
Hi,

I want to display xml-formatted string in a new window.
I tried this way:

function show_xml() {
var res = "<?xml version=\"1.0\" encoding=\"ISO-8859-2\"?>
<blub id=\"123\"></blub>
<blib id=\"453\"></blib>
";
var newWindow = window.open("","new");
newWindow.document.open("text/xml");
newWindow.document.write(res);
}

problems:
- how to remove the line breaks, because the string has really this breaks inside.
- after putting the string on one line manually, the result is a blank page, nothing inside..

so, how can I display a xml string in a new window ??

thanks in advance ..:GERD:..

khalidali63
04-01-2003, 09:22 AM
I could be wrong,but I dont thing you can create a new xml document using javascript.Ofcourse you can add or delete elements.

Now taking a look at the xml you are creating,its not a valid xml file

<?xml version="1.0" encoding="ISO-8859-2"?>
<blub id="123"></blub>
<blib id="453"></blib>


XML only allows one top level element,your xml should be in this format


<?xml version="1.0" encoding="ISO-8859-2"?>
<root>
<blub id="123"></blub>
<blib id="453"></blib>
</root>

If you save the xml file say in temp.xml file and then open it using new window
newWin = window.open("temp.xml","newWin")

this will show xml document in the new window.

hope this helps

Cheers

Khalid