Writing XML

Discussion in 'XML' started by Jim, Jun 2, 2006.

  1. Jim

    Jim Guest

    Hi folks,

    Could anyone help me with this one?

    I want to put something on my website were people can leave their email
    address to sign up for our newsletter. I've tried using JScript that writes
    to an xml file.

    When you click on 'enter' you are redirected to the 'done.html'. I've set
    write permissions to the xml file but it doesn't seem to be working, can
    anyone see what I'm doing wrong?



    add.html
    ---------
    <html>
    <body>
    <form name="add_email" method="post" action="add.asp">
    <table>
    <tr>
    <td><p>Enter email</p></td>
    <td><input type="text" name="email" id="email"></td>
    <td><input type="submit" name="submit" value="enter"></td>
    </tr>
    </table>
    </form>
    </body>
    </html>



    add.asp
    --------
    <%@ Language=JScript%>

    <%

    var email = Request.Form("email")

    var xmlDoc=Server.CreateObject("MICROSOFT.FreeThreadedXMLDOM");
    xmlDoc.async="false";
    xmlDoc.load(Server.MapPath("/test/email_address.xml"));

    var nodeList = xmlDoc.getElementsByTagName("address");

    if(nodeList.length > 0){

    var parentNode = nodeList(0);
    var addressNode = xmlDoc.createElement("address");
    var emailNode = xmlDoc.createElement("email");

    addressNode.text = address;
    emailNode.text = email;

    parentNode.appendChild(addressNode);
    addressNode.appendChild(emailNode);

    xmlDoc.save(Server.MapPath("/test/email_address.xml"));

    }

    Response.Redirect("done.html")

    %>



    email_address.xml
    -------------------
    <address>
    <email></email>
    <email></email>
    <email></email>
    </address>
    Jim, Jun 2, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HNguyen
    Replies:
    4
    Views:
    2,401
    HNguyen
    Dec 21, 2004
  2. Bomb Diggy
    Replies:
    0
    Views:
    441
    Bomb Diggy
    Jul 28, 2004
  3. Christopher Boomer
    Replies:
    0
    Views:
    407
    Christopher Boomer
    Jul 28, 2003
  4. Tony Prichard
    Replies:
    0
    Views:
    725
    Tony Prichard
    Dec 12, 2003
  5. Erik Wasser
    Replies:
    5
    Views:
    452
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page