How to export content from a JS Dom object

K

Ksou

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.
 
M

Martin Honnen

Ksou said:
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.
 
K

Ksou

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)
 
M

Martin Honnen

Ksou said:
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.
 
K

Ksou

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
 
M

Martin Honnen

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

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,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top