473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

XMLHttpRequest for *creating* XML documents?

Heya,

I have been looking all over Google for ways to *create* an XML document
using any Javascript object, and it seems that no one has ever tried or
ever needed this.

I want to send the server some info dynamically created on the page, and
instead of sending a complicated GET request with the info, or creating
an XML using my own set of functions, is there any object that allows
you to use the Document Object Model, like adding nodes, etc, and then
output the XML text at the end you could then send to the server? It
seems XMLHttpRequest is only for requests, and I don't want to use
Microsoft-only ActiveX XML objects.

Any idea?

Thanks,

------
William
Jun 16 '06 #1
9 2044
XMLHttpRequest is supported on various browsers nowadays, although in
different ways.

William wrote:
Heya,

I have been looking all over Google for ways to *create* an XML document
using any Javascript object, and it seems that no one has ever tried or
ever needed this.

I want to send the server some info dynamically created on the page, and
instead of sending a complicated GET request with the info, or creating
an XML using my own set of functions, is there any object that allows
you to use the Document Object Model, like adding nodes, etc, and then
output the XML text at the end you could then send to the server? It
seems XMLHttpRequest is only for requests, and I don't want to use
Microsoft-only ActiveX XML objects.

Any idea?

Thanks,

------
William


Jun 16 '06 #2
William wrote:
Heya,

I have been looking all over Google for ways to *create* an XML document
using any Javascript object, and it seems that no one has ever tried or
ever needed this.


Look a little harder ;-) try the W3 Load and Save spec:

"a platform- and language-neutral interface that allows programs
and scripts to dynamically load the content of an XML document
into a DOM document and serialize a DOM document into an
XML document"

<URL:http://www.w3.org/TR/DOM-Level-3-LS/>

However it's not well supported by browsers yet - at least it gives you
a starting point. There's some info here:

<URL:http://developer.mozilla.org/en/docs/XML_in_Mozilla#DOM_Load_and_Save_Methods>
--
Rob

Jun 16 '06 #3
Hi,

William wrote:
Heya,

I have been looking all over Google for ways to *create* an XML document
using any Javascript object, and it seems that no one has ever tried or
ever needed this.

I want to send the server some info dynamically created on the page, and
instead of sending a complicated GET request with the info, or creating
an XML using my own set of functions, is there any object that allows
you to use the Document Object Model, like adding nodes, etc, and then
output the XML text at the end you could then send to the server? It
seems XMLHttpRequest is only for requests, and I don't want to use
Microsoft-only ActiveX XML objects.

Any idea?

Thanks,

------
William


The XML objects are not IE only, see
http://www.quirksmode.org/dom/importxml.html
for a cross-browser example. I implemented the example and tested in
Firefox, it works. Is that what you're looking for?

Greetings,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jun 16 '06 #4


William wrote:

I have been looking all over Google for ways to *create* an XML document
using any Javascript object, and it seems that no one has ever tried or
ever needed this.

Mozilla and Opera support the W3C DOM Level 2
var xmlDocument = document.implementation.createDocument('',
'root-element', null)
to start from scratch.

Then they both support DOMParser to start with parsing a string e.g.
var xmlDocument = new DOMParser().parseFromString(
'<gods><god>Kibo</god></gods>',
'application/xml'
);

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 16 '06 #5
Thanks, but if you read my message, I was saying that it doesnt support
creating XML documents, which is really want I want to do....
-----
William

NetOne wrote:
XMLHttpRequest is supported on various browsers nowadays, although in
different ways.

William wrote:
Heya,

I have been looking all over Google for ways to *create* an XML document
using any Javascript object, and it seems that no one has ever tried or
ever needed this.

I want to send the server some info dynamically created on the page, and
instead of sending a complicated GET request with the info, or creating
an XML using my own set of functions, is there any object that allows
you to use the Document Object Model, like adding nodes, etc, and then
output the XML text at the end you could then send to the server? It
seems XMLHttpRequest is only for requests, and I don't want to use
Microsoft-only ActiveX XML objects.

Any idea?

Thanks,

------
William

Jun 16 '06 #6
Thanks, but I've seen it, and it says:
Mozilla currently implements only the load() method
Not really helpful, cross platform solution I would say....

-------
William

RobG wrote: William wrote:
Heya,

I have been looking all over Google for ways to *create* an XML document
using any Javascript object, and it seems that no one has ever tried or
ever needed this.


Look a little harder ;-) try the W3 Load and Save spec:

"a platform- and language-neutral interface that allows programs
and scripts to dynamically load the content of an XML document
into a DOM document and serialize a DOM document into an
XML document"

<URL:http://www.w3.org/TR/DOM-Level-3-LS/>

However it's not well supported by browsers yet - at least it gives you
a starting point. There's some info here:

<URL:http://developer.mozilla.org/en/docs/XML_in_Mozilla#DOM_Load_and_Save_Methods>

Jun 16 '06 #7
Thanks for the answer, but I've seen this before, and again, I want to
*create* and *save* a document in a browser in Javascript, not load one,
and this example doesnt explain creating and saving an XML, just loading
one. I need something like:

var obj = new XMLDoc();
var item = obj.AddNode(a);
var item2 = obj.AddNode(b);
var xml = obj.contentXml;

and then be able to send this to a PHP page through XMLHttpRequest or
whatever.

So please if someone ever created and saved in a variable some XML text
created using DOM on a browser, let me know. I'm not talking about
making my own function to create the XML, but this is what I might end
up doing. I just thought it would be cleaner to use a DOM object, which
is more consistent with other widely used techniques.

-----
William

Laurent Bugnion wrote:
Hi,

William wrote:
Heya,

I have been looking all over Google for ways to *create* an XML
document using any Javascript object, and it seems that no one has
ever tried or ever needed this.

I want to send the server some info dynamically created on the page,
and instead of sending a complicated GET request with the info, or
creating an XML using my own set of functions, is there any object
that allows you to use the Document Object Model, like adding nodes,
etc, and then output the XML text at the end you could then send to
the server? It seems XMLHttpRequest is only for requests, and I don't
want to use Microsoft-only ActiveX XML objects.

Any idea?

Thanks,

------
William


The XML objects are not IE only, see
http://www.quirksmode.org/dom/importxml.html
for a cross-browser example. I implemented the example and tested in
Firefox, it works. Is that what you're looking for?

Greetings,
Laurent

Jun 16 '06 #8


William wrote:

I need something like:

var obj = new XMLDoc();
var xmlDoc = document.implementation.createDocument('',
'root-element', null);
var item = obj.AddNode(a);
var element = xmlDoc.createElement('child');
element.appendChild(xmlDoc.createTextNode('Kibolog y for all.'));
xmlDoc.documentElement.appendChild(element);
and then be able to send this to a PHP page through XMLHttpRequest


The send method takes a DOM node like a DOM XML document as the argument
so you can POST the xmlDoc created above to the server.

Code works with Mozilla and Opera at least, not sure about Safari,Konqueror.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 16 '06 #9

"William" <wi*****@metaNOyer.inSPAMfowrote in message
news:yl********************@weber.videotron.net...
Heya,

I have been looking all over Google for ways to *create* an XML document
using any Javascript object, and it seems that no one has ever tried or
ever needed this.

I want to send the server some info dynamically created on the page, and
instead of sending a complicated GET request with the info, or creating an
XML using my own set of functions, is there any object that allows you to
use the Document Object Model, like adding nodes, etc, and then output the
XML text at the end you could then send to the server? It seems
XMLHttpRequest is only for requests, and I don't want to use
Microsoft-only ActiveX XML objects.
DP_YODEL will convert a JavaScript object to an XML object using the YODEL
spec:

http://www.depressedpress.com/Conten...ODEL/Index.cfm

XML-RPC and WDDX are other (more popular, but since I wrote YODEL I gave it
top billing) options that have JavaScript serialization libraries.

In general this makes things pretty easy: you create a native JavaScript
object that represents the data you want to pass, pump it through a nice
black-box object which converts it to XML and pass it on up. The server
would have a related object which would deserialize the data.

Jim Davis

Jul 11 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chris Smith | last post by:
This is a bit of a weird problem. Unfortunately, I can't reproduce it in a simple example, so I can only poke it out there and see if anyone has seen something similar. I have a script that...
2
by: Marco Laponder | last post by:
Hi All, I am using XmlHttpRequest object within Firefox to get a xml document from the servlet. The reponseText is set but the responseXml is null. My Code is: req = new XMLHttpRequest();...
10
by: Matt Kruse | last post by:
I'm aware of the circular reference memory leak problem with IE/closures. I'm not sure exactly how to resolve it in this situation. Also, Firefox appears to grow its memory size with the same code....
22
by: googlegroups | last post by:
I am playing with the XMLHTTPRequest method to perform client/server transactions. I have it set up right now so that when readyState is 4, it takes the XML and processes it. This works great until...
12
by: steveH | last post by:
Hi, I'm trying to solve a problem for a user which I can neither reproduce or explain. Here goes in the hope that someone else may have experienced the same. I make two attempts to create the...
25
by: Matt Kruse | last post by:
According to HTTP/1.1 specs, a client should only have two connections open to the host at a time (which can be changed by browser users, of course). When using xmlHttpRequest connections, is...
1
by: ScriptProblem | last post by:
Hi Guys, I have a security concern with Mozilla and Netscape browsers(In IE it gives secuirity pop window) in Remote server(Client's server).When I am trying to call an Asp.NET web service from...
1
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest...
6
by: Patrick Nolan | last post by:
I'm working on cross-platform portability of some javascript. My Macintosh testing platform is rather old. It has Safari 1.3.2 and Internet Explorer 5.2. I got Safari working, but now IE is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.