Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 24th, 2003, 12:39 PM
Registered User
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML DOM and Javascript

Hi everyone,

I've been struggling enough with this thing, so I decided to finally ask for help.

My web application consists of a series of htm pages that need be accessed as "steps" in a process.

I am using mainly XML DOM and java script in order to get the information typed by the users in the forms.

After filling the form in the first step, I need to "save" that information somehow and send it to the next page.

I am simulating serialization of an object, collecting all the input from the form and holding it as a string using a java script function:

function GetXML(fm)

      var strXML = new String();
      strXML = "<?xml version='1.0'?>\n";
      strXML = strXML + "<root>\n";
      strXML = strXML + "<name>\n";
      strXML = strXML + "\t<first>" + fm.First.value + "</first>\n";
      strXML = strXML + "\t<last>" + fm.Last.value + "</last>\n";
      strXML = strXML + "</name>\n";
      strXML = strXML + "<phones>\n";
      strXML = strXML + "\t<phoneno typeID='" + fm.PhoneType.value + "' type='" + fm.PhoneType.options[fm.PhoneType.selectedIndex].text + "'>" + fm.PhoneNo.value + "</phoneno>\n";
      strXML = strXML + "</phones>\n";
      strXML = strXML + "<email>" + fm.Email.value + "</email>\n";
      strXML = strXML + "<address street='" + fm.Street.value + "' city='" + fm.City.value + "' state='" + fm.State.value + "' zip='" + fm.Zip.value + "'></address>\n";
      strXML = strXML + "</root>";

     return (strXML); //this value will be returned and sent to the "next step"


My problem:
How do I access this xml document (returned by the function) in the next "step" of my application? Can I save it at the client, adding nodes to it, until I am ready to submit it to an .asp page for further processing???

I would appreciate any help I could get. This thing is pulling my brains out... :) Thanks...

Old September 25th, 2003, 01:57 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to armmarti

Hi Lilu,

here is the snippet which will help you I hope:
// Instantiate a DOM object.
var doc = new ActiveXObject("msxml2.DOMDocument.4.0");
doc.async = false;
doc.resolveExternals = false;
doc.validateOnParse = false;

// Load an XML doc into the DOM instance.
var xmlDocAsString = GetXML(form1);

// Save the dom to a file.
But this all needs MSXML4.0.

Old September 25th, 2003, 03:56 AM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

You can't save it to the client easily, it would be a security breach, unless you are sure that it's IE and you can use persistance behavior.
You can use frames and save the DomDocument object in a staic frame while the main frame changes as your wizard moves from step to step.


Old September 25th, 2003, 07:55 AM
Registered User
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Thank you so much for your replies. I am new to xmldom and wished I could do all this in asp, but unfortunately my app is using software that can only display the flash demos in htm pages.

Saving at the client would not be a big security issue in my case, as this app will run on our intranet only.

I think I will save the doc to the local drive on each client, then retrieve it in the next step and keep adding nodes to it. In the end I will post everything to an asp page that will save the data in xml format into a staging database (armmarti, I will let you know how this goes!).

Interesting solution with saving in a frame, joefawcett. I would like to know more about that. It would probably be the best thing to do if the saving to the drive does not work!

Thanks again,


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding altered DOM after JavaScript Manipulations lorlarz Javascript How-To 4 December 8th, 2007 05:20 PM
JavaScript, CSS, DOM - xBrowser Problem erobb Javascript 1 September 10th, 2006 06:44 AM
New JavaScript DOM article posted jminatel Javascript 0 August 26th, 2006 01:43 PM
Netscape Layers Using CSS+JavaScript(DOM) anshul Javascript How-To 2 May 26th, 2004 01:51 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.