1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Asp Xml Problem. Please Help!!

Discussion in 'C#' started by ordonyez, Nov 26, 2005.

  1. #1
    Hi,

    Im creating a forum using xml and asp. in my form to add a new post in my input tags i have the value as <% =Request( "userName" ) %> . This is to retreive the value and put it in a variable username. However, when I view the page my asp code is showing up in the input boxes. PLEASE HELP ME FIGURE THIS OUT!! Below is the code for this page. and attached is a screenshot of what I see when I open the asp page.



    <% @LANGUAGE = "VBScript" %>

    <%

    Option Explicit

    Dim xmlFile, xmlRoot, xmlNode
    Dim strTitle, strError, strPath

    If Request( "submit" ) <> Empty Then

    If Request( "file" ) <> Empty And _
    Request( "userName" ) <> Empty And _
    Request( "messageTitle" ) <> Empty And _
    Request( "messageText" ) <> Empty Then

    strPath = Server.MapPath( Request( "file") )

    Set xmlFile = Server.CreateObject( "Microsoft.XMLDOM" )
    xmlFile.Async = False

    If Not xmlFile.Load( strPath ) Then
    Call Server.Transfer( "invalid.html" )
    End If

    'get the root node
    Set xmlRoot = xmlFile.DocumentElement

    'create first message
    Set xmlNode = xmlFile.CreateElement( "message" )
    Call xmlNode.SetAttribute( "timestamp", Now & " EST" )
    Call xmlRoot.AppendChild( xmlNode )

    Set xmlRoot = xmlNode

    'Create User Node
    Call CreateElementNode( "user", "userName", xmlNode )


    'Create Title Node
    Call CreateElementNode( "title", "messageTitle", xmlNode )


    'Create Text Node
    Call CreateElementNode( "text", "messageText", xmlNode )

    'Save The File
    Call xmlFile.Save( strPath )

    'Finished Processing
    Call Server.Transfer( Request( "file" ) )

    Else
    strError = "ERROR: Invalid input."
    End If

    End If



    ' procedure that creates an element node

    Sub CreateElementNode( elementName, formElement, node )
    Set xmlNode = xmlFile.CreateElement( elementName )
    xmlNode.Text = Request( formElement )
    Call xmlRoot.AppendChild( node )
    End Sub
    %>


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns = "http://www.w3.org/1999/xhtml">

    <head>
    <title>Post A Message</title>
    <link rel= "stylesheet" type="text/css" href="style.css" />
    </head>

    <body>
    <p><% =strError %></p>

    <form method="post" action="addPost.asp">

    <p>
    User:<br />
    <input type = "text" size = "40" name= "userName" value="<% =Request( "userName" ) %>" />
    </p>


    <p>
    Message Title:<br />
    <input type="text" size="40" name="messageTitle" value= "<% =Request( "messageTitle" ) %>" />
    </p>

    <p>
    Message Text:<br />
    <textarea name="messageText" cols="40" rows="4"><% =Request( "messageText" ) %>
    </textarea>
    </p>

    <p>
    <input type="hidden" name="file" value= " <% =Request( "file" ) %> " />
    <input type="submit" name="submit" value="submit" />
    <input type="reset" value="Clear" />
    </p>
    </form>

    <p>
    <a href= "<% =Request( "file" ) %>" >Return to Forum</a>
    </p>
    </body>
    </html>
     

    Attached Files:

    ordonyez, Nov 26, 2005 IP
  2. mikmik

    mikmik Guest

    Messages:
    356
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You have to create the com object. You are trying to access somethig:
    that you have not created yet.


    <%
    Dim objDom
    Dim objRoot
    Dim objChild1
    Dim objChild2
    Dim objPI
    Set objDom = Server.CreateObject("Microsoft.XMLDOM")
    Set objRoot = objDom.createElement("rootElement")


    If php, this:"If Request( "submit" ) " would have to be "request" or "post", not "submit".

    Here I was going to learn asp and I end up php. But, I have good links:
    Storing your form submissions in XML
    It is all on that page. Another good one is
    and
    http://www.aspin.com/
    .net stuff mostly: http://www.15seconds.com/focus/XML.htm
    These guys rule for asp as well:
    http://www.xmlfiles.com/
    LMAO times 2!
    Asp is the way, my man!
    http://www.scriptsearch.com/XML/Tips_and_Tutorials/
    xmlPitStop - Scripts and tutorials, 90% asp..

    Ooops(It is all on that page.): http://www.scriptsearch.com/XML/Tips_and_Tutorials/
     
    mikmik, Nov 26, 2005 IP