How can I update an xml file on the server using xslt and .asp?
===

I have a flash site which gets it's very simple news page updated from an xml file. I want the user to be able to edit the xml online instead of editing it and uploading it via ftp. So far I've managed to create an xsl to view and edit the file. It has submit and reset buttons and the form calls an asp to then update the file and save it back to the server.

The news xml is very simple and has only 4 elements each with 2 attributes (well actually 3 but the date attribute is no longer used). I cannot change the structure because I cannot change the flash that's calling it.

I got this far by tinkering with a demo from http://www.w3schools.com/xsl/xsl_editxml.asp
however the example they give is not the same as my xml and it only updates one record.

So I've managed to view the page and edit it but I'm at a loss as to what to put in the asp file to cycle through the attibutes to save the new values.

Here is the simple xml file called newslist:

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="newslist.xsl"?>
    <News> 
        <newsItem newsdate=""  
              headline="This is headline 1"  
                   itemtxt="here is the text for news item one"  />  
    
         <newsItem newsdate=""  
                  headline="This is headline 2"  
                           itemtxt="here is the text for news item two"  />  
    
         <newsItem newsdate=""  
                  headline="This is headline 3"  
                           itemtxt="here is the text for news item three."  />  
    
         <newsItem newsdate=""  
                  headline="This is headline 4"  
                           itemtxt="here is the text for news item four"  /> 
    </News>

Here is the xsl

    {<?xml version="1.0" encoding="ISO-8859-1"?>
    
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
    <xsl:template match="/">
      <html>
      <body>
    <form method="post" action="newsedit.asp">
      <h2>News Page (EDIT):</h2>
      <table border="0">
        <tr bgcolor="#9acd32">
          <th>Item</th>
        <th size = "80">Text To Edit</th>
       
          
        </tr>
        <xsl:for-each select="News/newsItem">
    		
    			<tr>
    			  <td size="20"><strong>Headline</strong></td>
    			  <td size="80">
    			  <input type="text" size = "45">
    			  <xsl:attribute name="headline">
    				<xsl:value-of select="@headline" />
    			  </xsl:attribute>
    			    <xsl:attribute name="value">
    				<xsl:value-of select="@headline" />
    			  </xsl:attribute>
    			  </input>
    			  </td>
    			</tr>
    			<tr>
    			  <td size="20">News Item</td>
    			  <td size="80">
    			  <input type="textarea" size="120">
    			  
    			  
    			  <xsl:attribute name="itemtxt">
    				<xsl:value-of select="@itemtxt" />
    			  </xsl:attribute>
    			  <xsl:attribute name="value">
    				<xsl:value-of select="@itemtxt" />
    			  </xsl:attribute>
    			  </input>
    			  </td>
    			</tr>
    			<tr><td></td><td></td></tr>
    			<tr><td></td><td></td></tr>
    			<tr><td></td><td></td></tr>
    		
        </xsl:for-each>
      </table>
    <br />
      <input type="submit" id="btn_sub" name="btn_sub" value="Submit" />
      <input type="reset" id="btn_res" name="btn_res" value="Reset" />
      </form>
      </body>
      </html>
    </xsl:template>
    
    </xsl:stylesheet>

 -------- the asp file as taken from the demo above  
- I've commented on the part I'm unsure of i.e. the looping area -
-------

    <%
    function loadFile(xmlfile,xslfile)
    Dim xmlDoc,xslDoc
    'Load XML file
    set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    xmlDoc.async = false
    xmlDoc.load(xmlfile)
    'Load XSL file
    set xslDoc = Server.CreateObject("Microsoft.XMLDOM")
    xslDoc.async = false
    xslDoc.load(xslfile)
    'Transform file
    Response.Write(xmlDoc.transformNode(xslDoc))
    end function
    
    function updateFile(xmlfile)
    Dim xmlDoc,rootEl,f
    Dim i
    'Load XML file
    set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    xmlDoc.async = false
    xmlDoc.load(xmlfile)
    
    'Set the rootEl variable equal to the root element
    Set rootEl = xmlDoc.documentElement
    
    'Loop through the form collection
    for i = 1 To Request.Form.Count   ' this seems wrong for a start - It only ever gets to 1 and no farther
    
      'Eliminate button elements in the form
      if instr(1,Request.Form.Key(i),"btn_")=0 then
        'I don't know how to amend this section to cycle through each
    	' news item and each attribute on each news item
    	' to update them with the new values that were typed
    	
        set f = rootEl.selectSingleNode("field[@id='" & _
        Request.Form.Key(i) & "']/value")
        f.Text = Request.Form(i)
    
      end if
     ' response.write "Request.Form.key is; " & Request.Form.Key(i)
        
    next
    
    
    'Save the modified XML file
    xmlDoc.save xmlfile
    
    'Release all object references
    set xmlDoc=nothing
    set rootEl=nothing
    set f=nothing
    
    
    'Load the modified XML file with a style sheet that
    'allows the client to see the edited information
    loadFile xmlfile,server.MapPath("newsupdated.xsl")
    
    end function
    
    'If the form has been submitted update the
    'XML file and display result - if not,
    'transform the XML file for editing
    if Request.Form("btn_sub")="" then
      loadFile server.MapPath("newslist.xml"),server.MapPath("newslist.xsl")
    else
      updateFile server.MapPath("newslist.xml")
    end if
    
    %>

Any and all help much appreciated. I've struggled with this for ages and it's not comming together for me. - thank you for your time.
