Probably the first thing to nail down is what happens on the server versus
what happens on the client. On the server, you have an XML file and an XSLT
file. You load the XML file up into an XmlDocument class, load up an
XslTransform, and perform the transformation using XslTransform.Transform.
Does your code look kind of like this? Or are you using the asp:Xml control
to do the transformation?
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(Server.MapPath("data/xmlfile1.xml"));
System.Xml.Xsl.XslTransform trans = new System.Xml.Xsl.XslTransform();
trans.Load(Server.MapPath("xslt/xsltfile1.xslt"));
//transform the results directly to the output stream
trans.Transform(doc,null,Response.OutputStream,new
System.Xml.XmlUrlResolver());
From your description, I am guessing that the result of the transformation
is HTML, and you send the HTML to the client in the HTTP Response. You can
confirm this simply by viewing the page source in the browser.
Now that you have HTML in the browser, the HTML is parsed and the UI you see
with input boxes and buttons is rendered. As you input data into the UI
elements, you want that data to be sent *back to the server*, where the data
is saved? If this is the case, then this is completely possible. Or do you
want to save the data locally to the client's machine? If this is the case,
then this is not possible, since script in the browser purposefully does not
support file I/O.
Let's assume that you have an XML document that you want to update with the
values that the user was working with. There are a couple ways you can do
this.
One way is to use the Request.Form collection to read the values directly
out of the post.
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(Server.MapPath("data/xmlfile1.xml"));
if(!IsPostBack)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(Server.MapPath("data/xmlfile1.xml"));
System.Xml.Xsl.XslTransform trans = new System.Xml.Xsl.XslTransform();
trans.Load(Server.MapPath("xslt/xsltfile1.xslt"));
//transform the results directly to the output stream
trans.Transform(doc,null,Response.OutputStream,new
System.Xml.XmlUrlResolver());
}
else
{
System.Xml.XmlNode node = doc.SelectSingleNode("Customer/@ID");
node.Value = Request.Form["txtCustomerID"];
doc.Save(Server.MapPath("data/newxmlfile1.xml"));
}
Note that all of this code runs *completely on the server*. The net effect
of this code is to emit HTML back to the client within the HTTP response.
The client's browser knows nothing about XmlDocument.
You can also use client-side JavaScript to do lots of cool stuff, including
using a client-side IE Web Service Behavior that can call web services from
client-side JavaScript. You can also use IE Data Islands and work with XML.
You can create an MSXML.DOMDocument object on the client and work with XML,
then use the MSXML.XMLHTTP class to post the data to your web server. There
is lots of stuff you might do on the client, but the real question is "do
you really need to?" The example above shows how to update the XML document
using the XmlDocument class, is that enough? Or do you really need lots of
client-side JavaScript to manipulate the DOM in the client?
--
Kirk Allen Evans
www.xmlandasp.net
Read my web log at
http://weblogs.asp.net/kaevans
"Kathy Burke" <ka**********@attbi.com> wrote in message
news:#A**************@tk2msftngp13.phx.gbl...
Kirk,
Thank you SO much for answering...
I have a well formed (of course) xml file that when transformed with an
xsl stylesheet presents the user with a very prettily formatted document
of mfg process steps to follow.
There are some input boxes (e.g., in the xsl if the element <measure>
exists, xsl creates an input box) where when the user enters something,
I need to save it as part of the new document file (a record of what the
user has done).
Whenever I read things about this, it always says must do that stuff
"client side" via javascript. Of course, I realize I have to use
javascript, but don't get why if I'm using a .net xml web control to
specify the xml source and xsl transform file, that I'm now on client!
Of course, I realize asp.net results in html to the browser...sort of!!!
PLEASE show me an example of saving user-entered info within the
xmlDocument class? I don't want to save a "node" but the entire
document. See what I mean? Perhaps how to save the xmlDoc from within
the html javascript code?
Again, thanks for responding! I really appreciate it.
Kathy
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!