How Can I display XML file?

Z

Zhan feng Wang

Hi,friends,
I have a XML string, such as xs="<?xml version='1.0' ?><testh><test1
1/><test2 2/></testh>",how can I display(current window or a new window)
it as XML like:
−<testh>
<test1> 1 </test1>
<test2> 2 </test2>
</testh
I wrote as following, but do not work:
print "<script language=\"javascript\">\nfunction t(){\n"
print "document.write('",xs,"');\n"
print "}\nt();</script>\n"
or as:
print "<script language=javascript>\n"
print "winx=open('','XML','menubar,scrollbars,resizeable');\n"
print "winx.document.writeln('xs');\n"

Anyone knows it?
Thanks
 
Z

Zhan feng Wang

the xml string is xs="<?xml version='1.0' ?><testh><test1> 1
</test1><test2> 2 </test2></testh>"

Thanks
 
S

Stéphane Wirtel

Zhan feng Wang a écrit :
Hi,friends,
I have a XML string, such as xs="<?xml version='1.0' ?><testh><test1
1/><test2 2/></testh>",how can I display(current window or a new window)
it as XML like:
−<testh>
<test1> 1 </test1>
<test2> 2 </test2>
</testh
I wrote as following, but do not work:
print "<script language=\"javascript\">\nfunction t(){\n"
print "document.write('",xs,"');\n"
print "}\nt();</script>\n"
or as:
print "<script language=javascript>\n"
print "winx=open('','XML','menubar,scrollbars,resizeable');\n"
print "winx.document.writeln('xs');\n"

Anyone knows it?
Thanks
You can use the Builder gem, to generate an indented xml stream.

Stef
 

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
474,264
Messages
2,571,315
Members
48,000
Latest member
SusannahSt

Latest Threads

Top