|
-
Apr 28th, 2004, 07:57 AM
#1
Thread Starter
Member
Server Scriting via XML
Hi, getting a small error with some of my code, just wondered if anyone knew where i was going wrong. Basically all i want it to do is if there are no records within the database, for it to write a statement saying just this. Is this possible with XML declerations in the coding... The code that i have at the moment is as follows
Code:
<%
response.ContentType = "text/xml"
Set ObjConn = Server.CreateObject("ADODB.Connection")
ObjConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("xml.mdb")
ObjConn.Open
sql="SELECT * FROM Fishing"
set rs=ObjConn.Execute(sql)
if rs.BOF and rs.EOF then
response.write("No Products Matching That Description")
else
rs.MoveFirst()
response.write("<?xml version='1.0' encoding='ISO-8859-1'?>")
response.write("<FatherGifts>")
while (not rs.EOF)
response.write ("<Fishing>")
response.write("<FishName>" & rs("FishName") & "</FishName>")
response.write("<FishPrice>" & rs("FishPrice") & "</FishPrice>")
response.write("<FishDesc>" & rs("FishDesc") & "</FishDesc>")
response.write ("</Fishing>")
rs.MoveNext()
wend
response.write("</FatherGifts>")
end if
rs.close()
ObjConn.close()
%>
Any help would be much appriciated!
-
Apr 28th, 2004, 08:00 AM
#2
Thread Starter
Member
lol sorry i forgot to post the error which is...
Invalid at the top level of the document. Error processing resource 'http://mmtprojects.herts.ac.uk/year4/mmt4-30/XML%20Group%2047/fish.asp'. Line 1, Position 1
No Products Matching That Description
^
-
Apr 28th, 2004, 09:26 AM
#3
that's because you've already sent out an XML header: response.ContentType = "text/xml"
To avoid this, you need to wrap the error msg within XML tags.
response.write("<error>No Products Matching That Description</error>")
TG
-
Apr 28th, 2004, 09:30 AM
#4
Thread Starter
Member
excellent, thanx for the help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|