473,788 Members | 2,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Generate XML from XMLDocument

I have an XMLDocument that my web page downloads and manipulates as a
response to user input. I have lots of JavaScript that acts as a
controller between my view (html) and my model (xml). That works fine.

Once the user's done editing, I want to send the modified XMLDocument
back up to my server (as XML). The problem is, I can't find a way to
use JavaScript to generate XML from an XMLDocument. Is there some
obvious API that I'm missing? I assume there's more than one way to do
it (one way for IE and one way for Mozilla, who knows how many others),
anybody want to share?

Jul 20 '05 #1
2 5066
br**@koehn.com wrote:
I have an XMLDocument that my web page downloads and manipulates as a
response to user input. I have lots of JavaScript that acts as a
controller between my view (html) and my model (xml). That works fine.

Once the user's done editing, I want to send the modified XMLDocument
back up to my server (as XML). The problem is, I can't find a way to
use JavaScript to generate XML from an XMLDocument. Is there some
obvious API that I'm missing? I assume there's more than one way to do
it (one way for IE and one way for Mozilla, who knows how many others),
anybody want to share?


You could send the XML file direct using an XMLHttpRequest object
(Mozilla and IE, although they may differ a little).

Alternatively, write the XML text to a hidden (HTML) field using the
[DOMDocument].xml property (IE) or an XMLSerializer object (Mozilla).
Jul 20 '05 #2


br**@koehn.com wrote:
I have an XMLDocument that my web page downloads and manipulates as a
response to user input. I have lots of JavaScript that acts as a
controller between my view (html) and my model (xml). That works fine.

Once the user's done editing, I want to send the modified XMLDocument
back up to my server (as XML). The problem is, I can't find a way to
use JavaScript to generate XML from an XMLDocument. Is there some
obvious API that I'm missing?


I think so, XMLHttpRequest in Mozilla browsers (Mozilla suite, Firefox,
Netscape 6/7), in latest Safari and Konqueror, and Microsoft.XMLHT TP in
IE 5/5.5/6 on Windows simply lets you pass in your XML document as a
parameter to the send method e.g.
var httpRequest;
if (typeof XMLHttpRequest != 'undefined') {
httpRequest = new XMLHttpRequest( );
}
else if (typeof ActiveXObject != 'undefined') {
httpRequest = new ActiveXObject(' Microsoft.XMLHT TP');
}
if (httpRequest) {
httpRequest.ope n('POST', 'XMLLoader.asp' , true);
httpRequest.onr eadystatechange = function (evt) {
if (httpRequest.re adyState == 4) {
if (httpRequest.st atus == 200) {
// process response here e.g.
// process httpRequest.res ponseXML
}
else .... handle other response status if needed
}
};
httpRequest.sen d(xmlDocument);
}

See
<http://www.faqts.com/knowledge_base/view.phtml/aid/17226/fid/616>
for details.

If you need to serialize an XML document to a string (that is not needed
for the above, XMLHttpRequest' s send method simply needs the document
object) then with MSXML there is the property named xml for DOM nodes thus
var xmlString = xmlDocument.xml ;
gives you the serialized XML as a string, with Mozilla you have
XMLSerializer e.g.
var xmlString = new XMLSerializer() .serializeToStr ing(xmlDocument );
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #3

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

Similar topics

1
2346
by: Tim:. | last post by:
Hi Can someone tell me how I generate a new XML file that I can then use with an XSLT file. I am trying to use an XML file generated from Microsoft Project or even better generate an XML file from the project file (MPP File) itself. Which I can then use with an XSLT file I am new to XML and want to create a project viewer using XML, ASP and XHTML. I have an idea of how this should work but would really appritiate any help someone can...
5
2004
by: Dario de Judicibus | last post by:
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>') ;
1
15007
by: brad | last post by:
I have an XMLDocument that my web page downloads and manipulates as a response to user input. I have lots of JavaScript that acts as a controller between my view (html) and my model (xml). That works fine. Once the user's done editing, I want to send the modified XMLDocument back up to my server (as XML). The problem is, I can't find a way to use JavaScript to generate XML from an XMLDocument. Is there some obvious API that I'm missing?...
1
1738
by: Ryan | last post by:
Can anyone point me to some examples of generating a complete XmlDocument given an XmlSchema object?
5
2590
by: skidz | last post by:
I am trying to write an application that will generate XSL files (trying to automat some of my development), but am having a heck of a time. I just don't fully grasp the namespace issues I am having. This is what I have so far: ---------------------------------Code XmlDocument doc = new XmlDocument(); doc.AppendChild(doc.CreateXmlDeclaration ("1.0","UTF-8", string.Empty)); XmlNode root = doc.AppendChild(doc.CreateElement
2
1308
by: Blair Chen | last post by:
Pls help me out I am trying to generate xml file via XmlDocument class. I ceated a XmlDocument instance, how can I convert it to a physical xml file(e.g. test.xml)? following is the code: //add root XmlElement rootNode = xmlDoc.CreateElement("root"); rootNode.SetAttribute("root", root); xmlDoc.AppendChild(rootNode);
0
2555
by: taylorjonl | last post by:
I am having a problem generating some soap proxies dynamically using almost the exact same code as in the MSDN sample. http://msdn2.microsoft.com/en-us/library/system.web.services.description.webreference(VS.80).aspx It has very few differences, mainly I had to manipulate the document to remove the Any tags that caused 400+ validation warnings but even after getting the WebReference object ValidationWarnings to 0, it says...
1
1541
by: Abhijit D. Babar | last post by:
Hello, I have to generate XML file as follow, using XmlDocument. <Company> < Employee EID=”111” Description=” xyz”> <Dept DeptNo=”D10”> <FirstNameAbhijit </FirstName> <LastNameBabar </LastName> </Dept>
0
1269
by: Abhijit D. Babar | last post by:
Hello, I have to generate XML file as follow, using XmlDocument. <Company> < Employee EID=”111” Description=” xyz”> <Dept DeptNo=”D10”> <FirstNameAbhijit </FirstName> <LastNameBabar </LastName> </Dept>
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10172
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.