How to export content from a JS Dom object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ksou

    How to export content from a JS Dom object

    I would like to ask how can I submit a dom object content (e.g. xml content)
    from client side to server by using javascript.
    Or is there any method that I can invoke at dom object to obtain its
    content.
    Notice: The dom object is a javascript object.


  • Martin Honnen

    #2
    Re: How to export content from a JS Dom object



    Ksou wrote:
    [color=blue]
    > I would like to ask how can I submit a dom object content (e.g. xml content)
    > from client side to server by using javascript.[/color]

    With XMLHttpRequest the send method can take an XML document object, see
    <http://unstable.elemen tal.com/mozilla/build/latest/mozilla/extensions/dox/interfacensIXML HttpRequest.htm l#a5>
    so you would simply pass the XML DOM document object to the send method
    after a proper open call with method POST or PUT.

    --

    Martin Honnen

    Comment

    • Ksou

      #3
      Re: How to export content from a JS Dom object

      does it work properly at IE???

      "Martin Honnen" <mahotrash@yaho o.de> wrote in message
      news:42ef9caf$0 $6966$9b4e6d93@ newsread2.arcor-online.net...[color=blue]
      >
      >
      > Ksou wrote:
      >[color=green]
      > > I would like to ask how can I submit a dom object content (e.g. xml[/color][/color]
      content)[color=blue][color=green]
      > > from client side to server by using javascript.[/color]
      >
      > With XMLHttpRequest the send method can take an XML document object, see
      >[/color]
      <http://unstable.elemental.com/mozill...tensions/dox/i
      nterfacensIXMLH ttpRequest.html #a5>[color=blue]
      > so you would simply pass the XML DOM document object to the send method
      > after a proper open call with method POST or PUT.
      >
      > --
      >
      > Martin Honnen
      > http://JavaScript.FAQTs.com/[/color]


      Comment

      • Martin Honnen

        #4
        Re: How to export content from a JS Dom object



        Ksou wrote:
        [color=blue]
        > does it work properly at IE???[/color]

        Sure, but only if you pass an XML DOM document to the send method of the
        XMLHTTP object. Don't expect to be able to pass an HTML DOM document to
        that method. MSXML implements the XML DOM and that is separate from the
        HTML DOM that IE (or technically MSHTML) implements, both are accessible
        with script but objects from one DOM implementation cannot be inserted
        into objects of the other DOM implementation.


        --

        Martin Honnen

        Comment

        • Ksou

          #5
          Re: How to export content from a JS Dom object

          how about a SVG Document object???
          As what I want is to upload the whole SVG document from client side to
          server side (a J2EE server)

          "Martin Honnen" <mahotrash@yaho o.de> wrote in message
          news:42efb3e3$0 $11749$9b4e6d93 @newsread4.arco r-online.net...[color=blue]
          >
          >
          > Ksou wrote:
          >[color=green]
          > > does it work properly at IE???[/color]
          >
          > Sure, but only if you pass an XML DOM document to the send method of the
          > XMLHTTP object. Don't expect to be able to pass an HTML DOM document to
          > that method. MSXML implements the XML DOM and that is separate from the
          > HTML DOM that IE (or technically MSHTML) implements, both are accessible
          > with script but objects from one DOM implementation cannot be inserted
          > into objects of the other DOM implementation.
          >
          >
          > --
          >
          > Martin Honnen
          > http://JavaScript.FAQTs.com/[/color]


          Comment

          • Martin Honnen

            #6
            Re: How to export content from a JS Dom object



            Ksou wrote:
            [color=blue]
            > how about a SVG Document object???
            > As what I want is to upload the whole SVG document from client side to
            > server side (a J2EE server)[/color]

            SVG is an XML application so you can certainly parse an SVG markup with
            MSXML in IE and post it to a server.
            But if your SVG document object is implemented by some third party stuff
            like Adobe SVG viewer then MSXML does not consume that document object,
            you need to either serialize the Adobe SVG document (I think there is a
            printNode method implemented in the viewer for that) and pass the
            serialized string to the send method of Microsoft.XMLHT TP or you can
            make use of the methods like postURL that Adobe SVG viewer implements.
            Methods like printNode or postURL used to be documented in the needed
            detail in the SVG wiki
            <http://wiki.svg.org/>
            but unfortunately that has been taken offline months ago.
            But as you have not even told whether you use Adobe SVG viewer or how
            exactly you use SVG on the client I guess it is easier that you post
            back if needed and tell us more details.
            Or you try the SVG group on groups.yahoo.co m.

            --

            Martin Honnen

            Comment

            • Ksou

              #7
              Re: How to export content from a JS Dom object

              I am using SVG viewer, I embeded the SVG file in an html file like this
              <object type="image/svg+xml" width="400" height="300">
              <embed src="map.svg" type="image/svg+xml" width="400" height="300">
              </object>
              and I got the SVG object by javascript like this
              function clickOnMap(evt) { svgDocument = evt.target.owne rDocument;}
              As the svg will be manipulated by users at client side, I would like to know
              how can I send the svg object/source(the most updated svg dom) to the
              server.Thanks"M artin Honnen" <mahotrash@yaho o.de> wrote in message
              news:42f0b115$0 $6983$9b4e6d93@ newsread2.arcor-online.net...[color=blue]
              >
              >
              > Ksou wrote:
              >[color=green]
              > > how about a SVG Document object???
              > > As what I want is to upload the whole SVG document from client side to
              > > server side (a J2EE server)[/color]
              >
              > SVG is an XML application so you can certainly parse an SVG markup with
              > MSXML in IE and post it to a server.
              > But if your SVG document object is implemented by some third party stuff
              > like Adobe SVG viewer then MSXML does not consume that document object,
              > you need to either serialize the Adobe SVG document (I think there is a
              > printNode method implemented in the viewer for that) and pass the
              > serialized string to the send method of Microsoft.XMLHT TP or you can
              > make use of the methods like postURL that Adobe SVG viewer implements.
              > Methods like printNode or postURL used to be documented in the needed
              > detail in the SVG wiki
              > <http://wiki.svg.org/>
              > but unfortunately that has been taken offline months ago.
              > But as you have not even told whether you use Adobe SVG viewer or how
              > exactly you use SVG on the client I guess it is easier that you post
              > back if needed and tell us more details.
              > Or you try the SVG group on groups.yahoo.co m.
              >
              > --
              >
              > Martin Honnen
              > http://JavaScript.FAQTs.com/[/color]


              Comment

              • Martin Honnen

                #8
                Re: How to export content from a JS Dom object



                Ksou wrote:
                [color=blue]
                > I am using SVG viewer, I embeded the SVG file in an html file like this
                > <object type="image/svg+xml" width="400" height="300">
                > <embed src="map.svg" type="image/svg+xml" width="400" height="300">
                > </object>
                > and I got the SVG object by javascript like this
                > function clickOnMap(evt) { svgDocument = evt.target.owne rDocument;}
                > As the svg will be manipulated by users at client side, I would like to know
                > how can I send the svg object/source(the most updated svg dom) to the
                > server.[/color]

                As said with script inside of an SVG document in Adobe SVG viewer you
                have a method named
                printNode
                which simply takes a DOM nodes and serializes it to a string e.g.
                var xmlMarkup = printNode(svgDo cument);
                should give you the serialized markup of the SVG DOM document object you
                have above.
                Then there is a method called
                postURL
                which you can use to send data to the server (making a HTTP POST
                request) so you could do
                postURL(
                'whatever.jsp',
                xmlMarkup,
                function (callbackResult ) {
                if (callbackResult .status == 200) {
                // process callbackResult. content here
                }
                }
                );
                to post the markup to the server.

                I am working from memory here and it has been a while that I have used
                those functions, if the above does not work you might want to ask on the
                SVG group on groups.yahoo.co m.

                --

                Martin Honnen

                Comment

                • Ksou

                  #9
                  Re: How to export content from a JS Dom object

                  Dear Martin,

                  The printNode() method does work very well.

                  Thank you very much!!!!

                  "Martin Honnen" <mahotrash@yaho o.de> wrote in message
                  news:42f0f623$0 $11759$9b4e6d93 @newsread4.arco r-online.net...[color=blue]
                  >
                  >
                  > Ksou wrote:
                  >[color=green]
                  > > I am using SVG viewer, I embeded the SVG file in an html file like this
                  > > <object type="image/svg+xml" width="400" height="300">
                  > > <embed src="map.svg" type="image/svg+xml" width="400" height="300">
                  > > </object>
                  > > and I got the SVG object by javascript like this
                  > > function clickOnMap(evt) { svgDocument = evt.target.owne rDocument;}
                  > > As the svg will be manipulated by users at client side, I would like to[/color][/color]
                  know[color=blue][color=green]
                  > > how can I send the svg object/source(the most updated svg dom) to the
                  > > server.[/color]
                  >
                  > As said with script inside of an SVG document in Adobe SVG viewer you
                  > have a method named
                  > printNode
                  > which simply takes a DOM nodes and serializes it to a string e.g.
                  > var xmlMarkup = printNode(svgDo cument);
                  > should give you the serialized markup of the SVG DOM document object you
                  > have above.
                  > Then there is a method called
                  > postURL
                  > which you can use to send data to the server (making a HTTP POST
                  > request) so you could do
                  > postURL(
                  > 'whatever.jsp',
                  > xmlMarkup,
                  > function (callbackResult ) {
                  > if (callbackResult .status == 200) {
                  > // process callbackResult. content here
                  > }
                  > }
                  > );
                  > to post the markup to the server.
                  >
                  > I am working from memory here and it has been a while that I have used
                  > those functions, if the above does not work you might want to ask on the
                  > SVG group on groups.yahoo.co m.
                  >
                  > --
                  >
                  > Martin Honnen
                  > http://JavaScript.FAQTs.com/[/color]


                  Comment

                  Working...