By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,605 Members | 2,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,605 IT Pros & Developers. It's quick & easy.

writing xml to a ModalDialog window

P: 1
I am trying to display xml content in a modaldialog window using window.showModalDialog(), but a blank modaldialog window is displayed.

can anyone help me with this. Any other way present to display xml in modal dialog window and also to dispaly both html and xml content in a single modaldialog.

Any help would be appreciated.

Thanks in advance.
Praan
Aug 29 '06 #1
Share this Question
Share on Google+
6 Replies


P: 4
I am trying to display xml content in a modaldialog window using window.showModalDialog(), but a blank modaldialog window is displayed.
I am having the same problem - does anyone have an answer?

------------ Example---------------------
eg01.xml
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <?xml-stylesheet type="text/xsl" href="eg01.xsl" ?>
  3. <catalog>
  4.   <cd>
  5.     <title>Empire Burlesque</title>
  6.     <artist>Bob Dylan</artist>
  7.     <country>USA</country>
  8.     <company>Columbia</company>
  9.     <price>10.90</price>
  10.     <year>1985</year>
  11.   </cd>
  12. </catalog>
  13.  
eg01.xsl
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="1.0"
  3. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4. <xsl:template match="/">
  5.   <html>
  6.   <body>
  7.     <h2>My CD Collection</h2>
  8.     <table border="1">
  9.     <tr bgcolor="#9acd32">
  10.       <th align="left">Title</th>
  11.       <th align="left">Artist</th>
  12.     </tr>
  13.     <xsl:for-each select="catalog/cd">
  14.     <tr>
  15.       <td><xsl:value-of select="title"/></td>
  16.       <td><xsl:value-of select="artist"/></td>
  17.     </tr>
  18.     </xsl:for-each>
  19.     </table>
  20.   </body>
  21.   </html>
  22. </xsl:template>
  23. </xsl:stylesheet>
  24.  
TestModalXML.html
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <TITLE class="title">
  4. Testing XML via Modal dialog
  5. </TITLE>
  6. </head>
  7. <body>
  8. <INPUT TYPE="BUTTON" NAME="xxx" VALUE="show modal dialog" onClick="showModalDialog('http://xxx.xxx/eg01.xml',1,'dialogWidth:1024px; dialogHeight:768px; center:yes')">
  9. </body>
  10. </html>
  11.  
Aug 1 '07 #2

acoder
Expert Mod 15k+
P: 16,027
showModalDialog only works in IE. Try to use a standard window.open instead.
Aug 1 '07 #3

P: 4
showModalDialog only works in IE. Try to use a standard window.open instead.
1) I only need it to work in IE
(users access the intranet site I'm working on via locked down PC's)

2) I idealy need the XML to be displayed in a modal dialog, as opposed to just displaying it in a new window
Aug 1 '07 #4

acoder
Expert Mod 15k+
P: 16,027
1) I only need it to work in IE
(users access the intranet site I'm working on via locked down PC's)

2) I idealy need the XML to be displayed in a modal dialog, as opposed to just displaying it in a new window
I can suggest you this link. Let me know if it works.
Aug 1 '07 #5

P: 4
I can suggest you this link. Let me know if it works.
A useful link, Thanks :)

It doesn't solve my problem unfortunately as the url I want to pass as an argument to the showModalDialog returns the XML I'm trying to display thus I can't pass the xml to the ModalDialog as a dialogArgument as their example does.

It also doesn't explain why
Expand|Select|Wrap|Line Numbers
  1. showModalDialog("http://xxx.xxx/eg01.xml")
  2.  
doesn't work but
Expand|Select|Wrap|Line Numbers
  1. window.open("http://xxx.xxx/eg01.xml")
  2.  
does.

It has given me some ideas for a possible work around though, which I'm going to persue
Aug 2 '07 #6

P: 4
I can suggest you this link. Let me know if it works.
The link turned out to be very useful thanks!!!

1) Based on what I've seen looking at this issue I think that the problem stems from the modal dialog ignoring the mime type and treating the xml as html

2) The solution I've got working, if not particularly tidily, relies on javascript loading the xml into an html page on load.......

change the url passeed to the modal dialog in TestModalXML.html
Expand|Select|Wrap|Line Numbers
  1. ...showModalDialog('http://xxx.xxx/eg01.html'....
  2.  
eg01.html
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.  
  4. <XML id="eg01xml">
  5. <catalog>
  6.   <cd>
  7.     <title>Empire Burlesque</title>
  8.     <artist>Bob Dylan</artist>
  9.     <country>USA</country>
  10.     <company>Columbia</company>
  11.     <price>10.90</price>
  12.     <year>1985</year>
  13.   </cd>
  14. </catalog>
  15. </XML>
  16.  
  17. <XML id="eg01xsl">
  18. <xsl:stylesheet version="1.0"
  19. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  20.  
  21. <xsl:template match="/">
  22.   <html>
  23.   <body>
  24.     <h2>My CD Collection</h2>
  25.     <table border="1">
  26.     <tr bgcolor="#9acd32">
  27.       <th align="left">Title</th>
  28.       <th align="left">Artist</th>
  29.     </tr>
  30.     <xsl:for-each select="catalog/cd">
  31.     <tr>
  32.       <td><xsl:value-of select="title"/></td>
  33.       <td><xsl:value-of select="artist"/></td>
  34.     </tr>
  35.     </xsl:for-each>
  36.     </table>
  37.   </body>
  38.   </html>
  39. </xsl:template>
  40.  
  41. </xsl:stylesheet>
  42. </XML>
  43.  
  44. <script type="text/javascript">
  45.  function testLoad() {
  46. var xmldom = new ActiveXObject("msxml2.DOMDocument");
  47. xmldom.async = false;
  48. xmldom.resolveExternals = false;
  49. xmldom.loadXML(eg01xml.innerHTML);
  50. var xsldom = new ActiveXObject("msxml2.DOMDocument");
  51. xsldom.async = false;
  52. xsldom.resolveExternals = false;
  53. xsldom.loadXML(eg01xsl.innerHTML);
  54. var outputdom = new ActiveXObject("msxml2.DOMDocument");
  55. outputdom.async = false;
  56. outputdom.resolveExternals = false;
  57. xmldom.transformNodeToObject(xsldom, outputdom);
  58. divTarget.innerHTML = outputdom.xml;
  59.  }
  60.  
  61. </script>
  62. </head>
  63. <body onLoad="testLoad()">
  64. <div id="divTarget"></div>
  65. </body>
  66. </html> 
  67.  
Aug 3 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.