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

How to export content from a JS Dom object

P: n/a
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.
Aug 2 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a


Ksou wrote:
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.


With XMLHttpRequest the send method can take an XML document object, see
<http://unstable.elemental.com/mozilla/build/latest/mozilla/extensions/dox/interfacensIXMLHttpRequest.html#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
http://JavaScript.FAQTs.com/
Aug 2 '05 #2

P: n/a
does it work properly at IE???

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:42**********************@newsread2.arcor-online.net...


Ksou wrote:
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.
With XMLHttpRequest the send method can take an XML document object, see

<http://unstable.elemental.com/mozill...tensions/dox/i
nterfacensIXMLHttpRequest.html#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
http://JavaScript.FAQTs.com/

Aug 2 '05 #3

P: n/a


Ksou wrote:
does it work properly at IE???


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/
Aug 2 '05 #4

P: n/a
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" <ma*******@yahoo.de> wrote in message
news:42***********************@newsread4.arcor-online.net...


Ksou wrote:
does it work properly at IE???


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/

Aug 3 '05 #5

P: n/a


Ksou wrote:
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)


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.XMLHTTP 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.com.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 3 '05 #6

P: n/a
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.ownerDocument;}
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"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:42**********************@newsread2.arcor-online.net...


Ksou wrote:
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)


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.XMLHTTP 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.com.

--

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

Aug 3 '05 #7

P: n/a


Ksou wrote:
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.ownerDocument;}
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.


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(svgDocument);
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.com.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 3 '05 #8

P: n/a
Dear Martin,

The printNode() method does work very well.

Thank you very much!!!!

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:42***********************@newsread4.arcor-online.net...


Ksou wrote:
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.ownerDocument;}
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.


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(svgDocument);
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.com.

--

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

Aug 8 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.