Hookah - Loans - Debt Consolidation - Mortgages - Loans

PDA

View Full Version : Asp Xml Problem. Please Help!!


ordonyez
Nov 26th 2005, 12:19 pm
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>

mikmik
Nov 26th 2005, 12:44 pm
You have to create the com object. You are trying to access somethig:
Dim xmlFile, xmlRoot, xmlNode
Dim strTitle, strError, strPath

If Request( "submit" ) <> Empty Then

If Request( "file" ) <> Empty And
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 (http://www.asp101.com/articles/michael/htmlxml/default.asp)
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!
http://aspalliance.com/487 One of the most frequent tasks that web developers receive is that of creating a form to collect user input. One solution is to use an ASP.NET web page to create an XML file that will be used as the basis for a web form. The three part article, XML Form Generator, will demonstrate how to easily create an XML form that will save user input as an XML file. By using the run sample link above you view all the source code and see an online demo.
Asp is the way, my man!
http://www.scriptsearch.com/XML/Tips_and_Tutorials/
xmlPitStop (http://www.xmlpitstop.com/ListTutorials/DispContentType/XML/PageNumber/1.aspx) - Scripts and tutorials, 90% asp..

Ooops(It is all on that page.): http://www.scriptsearch.com/XML/Tips_and_Tutorials/