open new window as XML

S

ShayHk

Hi.. I want to open a new window in javascript
the new window will contain an xml message.. can I do this?
I dont want to use a xHtml file to contain the message
I just want to open the new window with the message insid of it.


for example:
xmlMessage = "<root><abc>123</abc></root>";
openXHTMLwindow(xmlMessage);

function openXHTMLwindow(xmlMessage)
{
OpenWindow=window.open("", "newwin",
"height=400,menubar=no,modal=yes'");
OpenWindow.document.write("<TITLE>Title Goes Here</TITLE>")
OpenWindow.document.write("<BODY")

OpenWindow.document.write(xmlMessage)

OpenWindow.document.write("</BODY>")
OpenWindow.document.write("</HTML>")
OpenWindow.document.close()
}
 
G

GArlington

Hi.. I want to open a new window in javascript
the new window will contain an xml message.. can I do this?
I dont want to use a xHtml file to contain the message
I just want to open the new window with the message insid of it.

for example:
xmlMessage = "<root><abc>123</abc></root>";
openXHTMLwindow(xmlMessage);

function openXHTMLwindow(xmlMessage)
{
OpenWindow=window.open("", "newwin",
"height=400,menubar=no,modal=yes'");
OpenWindow.document.write("<TITLE>Title Goes Here</TITLE>")
OpenWindow.document.write("<BODY")

OpenWindow.document.write(xmlMessage)

OpenWindow.document.write("</BODY>")
OpenWindow.document.write("</HTML>")
OpenWindow.document.close()

}

Check the docs about how document.write() works and you will see the
error of your ways...
 
G

GArlington

So what is the right way?
how can open a window with an XML as it's content

Once your script finished running look at the source of your newly
opened window...
 
T

Thomas 'PointedEars' Lahn

ShayHk said:
Hi.. I want to open a new window in javascript
the new window will contain an xml message.. can I do this?
I dont want to use a xHtml file to contain the message
I just want to open the new window with the message insid of it.

[...]
OpenWindow=window.open("", "newwin", "height=400,menubar=no,modal=yes'");
^[1] [2]^

[1] Identifiers that do not designate constructors should not start with a
capital letter. More important, all identifiers should be declared:

var w = window.open("", "...", "...");

or

var w;

function foo()
{
w = ...
}

[2] You have an extra apostrophe in the features string which might
invalidate it.
OpenWindow.document.write("<TITLE>Title Goes Here</TITLE>") ^^^^^ ^^^^^
OpenWindow.document.write("<BODY") ^^^^^
^^^^
OpenWindow.document.write("</HTML>")
^^^^

First, you have to make sure if you want to have any chance of creating an
XML document is that both the generating and the generated markup are Valid.

I don't know about your generating markup, but your generated markup is not
Valid. Not only well-formedness as required by XML is not met because you
have not closed the start tag of the `BODY' element, but you have also not
declared any element type that you are using. If this should be XHTML, you
have to declare the XHTML namespace and all element type identifiers ("tag
names") have to be in lowercase.

http://validator.w3.org/
http://www.w3.org/TR/xml/
http://www.w3.org/TR/xhtml1/

Second, you need a user agent that fully supports XML, and maybe even an XML
DOM. And if this is going to be XHTML, you need a UA that supports XHTML as
an application of XML instead of falsely error-corrected tag soup. That
would not apply to Microsoft Internet Explorer to date, for example.

http://www.spartanicus.utvinternet.ie/no-xhtml.htm

Don't make consecutive calls to document.write(). Call it only once and
build the string argument before. In its simplest form:

w.document.write(
"<title>Title Goes Here</title>"
+ "<body"
+ xmlMessage
+ "</body>"
+ "</html>"
);

Other, more efficient approaches, for example including Array objects, have
been posted here before.

(Note that this still needs work before it generates a Valid X[HT]ML document.)


HTH

PointedEars, with a fitting random signature
 
S

ShayHk

No. I dont think that you undrestood the problem.

The problem is that I have a dynamic XML string (on javascript)
I want to open the dynamic xml in a new window that the xml will be
it's content(well formed like xml)

maybe there is away to plant the xml string inside a xhtml file.
the main problem that the xml is dynamic.
 
T

Thomas 'PointedEars' Lahn

ShayHk said:
No. I dont think that you undrestood the problem.

I don't think that you have properly read and understood what I have written.
The problem is that I have a dynamic XML string (on javascript)
I want to open the dynamic xml in a new window that the xml will be
it's content(well formed like xml)

maybe there is away to plant the xml string inside a xhtml file.
the main problem that the xml is dynamic.

The main problem is that your generated markup so far is invalid, especially
as you also include XML.


PointedEars
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top