Generate XML by Javascript in IE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dario de Judicibus

    #1

    Generate XML by Javascript in IE

    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

    ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~


  • Jeff North

    #2
    Re: Generate XML by Javascript in IE

    On Fri, 26 Nov 2004 13:06:38 +0100, in comp.lang.javas cript "Dario de
    Judicibus" <nospam@nowhere .com> wrote:
    [color=blue]
    >| 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?[/color]

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

    Just guessing.
    ---------------------------------------------------------------
    jnorth@yourpant sbigpond.net.au : Remove your pants to reply
    ---------------------------------------------------------------

    Comment

    • Martin Honnen

      #3
      Re: Generate XML by Javascript in IE



      Dario de Judicibus wrote:
      [color=blue]
      > 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[/color]

      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.writin g
      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.

      --

      Martin Honnen
      http://JavaScript.FAQTs.com/

      Comment

      • Dario de Judicibus

        #4
        Re: Generate XML by Javascript in IE

        Jeff North wrote:[color=blue]
        > On Fri, 26 Nov 2004 13:06:38 +0100, in comp.lang.javas cript "Dario de
        > Judicibus" <nospam@nowhere .com> wrote:
        >[/color]
        ....[color=blue]
        >
        > maybe:
        > top.x.document. close();[/color]

        Of course I close. It's not that.

        DdJ


        Comment

        • Dario de Judicibus

          #5
          Re: Generate XML by Javascript in IE

          Martin Honnen wrote:[color=blue]
          > Dario de Judicibus wrote:
          >[/color]
          .....[color=blue]
          > 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.writin g
          > 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.[/color]

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

          DdJ


          Comment

          • Martin Honnen

            #6
            Re: Generate XML by Javascript in IE



            Dario de Judicibus wrote:
            [color=blue]
            > Martin Honnen wrote:
            >[color=green]
            >>Dario de Judicibus wrote:
            >>[/color]
            >
            > ....
            >[color=green]
            >>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.writin g
            >>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.[/color]
            >
            >
            > So, THAT is the problem... IE! I cannot generate XML on server. I need to do
            > it on client side... But how?[/color]

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


            var xmlDocument = new ActiveXObject(' Microsoft.XMLDO M');
            xmlDocument.asy nc = false;

            var wellFormed = xmlDocument.loa dXML('<gods><go d>Kibo</god></gods>');

            if (wellFormed) {
            alert(xmlDocume nt.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

            and run the transformation with script.

            --

            Martin Honnen
            http://JavaScript.FAQTs.com/

            Comment

            Working...