473,382 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to generate pure XML page with ASP?

How to generate pure XML page with ASP?
This try gave me an error:

XML Parsing Error: not well-formed
Location: http://www.worldincatalog.com/manage....asp?itemid=15
Line Number 2, Column 26: <font face="Arial" size=2>
-------------------------^

<% @ Language="VBScript" %>
<%
Option Explicit
Response.Buffer = True
Response.ContentType = "text/xml"

' Start XML document.
Response.Write "<?xml version=""1.0""?>" & vbCrLf
%>
<!-- #Include file="adocon.inc" -->
<%
Set rsItem = Server.CreateObject("ADODB.Recordset")
ItemSQL = "...xxx..."
rsItem.Open ItemSQL, adoCon
if not rsItem.eof then

Response.Write "<ItemXML>" & vbCrLf
Response.Write "<ItemID>"&rsItem("ItemID")&"</ItemID>" &
vbCrLf
Response.Write "</ItemXML>" & vbCrLf

end if
rsItem.close
set rsItem = nothing
set ItemSQL = nothing
set adoCon = nothing
%>

Apr 11 '07 #1
7 10891
vu******@gmail.com wrote on 11 Apr 2007 07:35:55 -0700:
How to generate pure XML page with ASP?
This try gave me an error:

XML Parsing Error: not well-formed
Location: http://www.worldincatalog.com/manage....asp?itemid=15
Line Number 2, Column 26: <font face="Arial" size=2>
-------------------------^
This tends to mean there's an error in the code, and the ASP debugger is
spitting out where the problem is, but your browser is trying to parse it as
XML. View the source to see the error message, or comment out the line
generating the xml header.

Dan
Apr 11 '07 #2
Option Explicit

you have the above set...
Set rsItem = Server.CreateObject("ADODB.Recordset")
ItemSQL = "...xxx..."
but I don't see these declared

Brian

Apr 11 '07 #3
On Apr 11, 2:18 pm, Brian Staff <brianstaff AT [NoSpam]cox DOT net>
wrote:
Option Explicit

you have the above set...
Set rsItem = Server.CreateObject("ADODB.Recordset")
ItemSQL = "...xxx..."

but I don't see these declared

Brian
they are declared. I just removed unnecessary stuff

Apr 11 '07 #4

<vu******@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
How to generate pure XML page with ASP?
This try gave me an error:

XML Parsing Error: not well-formed
Location: http://www.worldincatalog.com/manage....asp?itemid=15
Line Number 2, Column 26: <font face="Arial" size=2>
-------------------------^

<% @ Language="VBScript" %>
<%
Option Explicit
Response.Buffer = True
Response.ContentType = "text/xml"

' Start XML document.
Response.Write "<?xml version=""1.0""?>" & vbCrLf
%>
<!-- #Include file="adocon.inc" -->
<%
Set rsItem = Server.CreateObject("ADODB.Recordset")
ItemSQL = "...xxx..."
rsItem.Open ItemSQL, adoCon
if not rsItem.eof then

Response.Write "<ItemXML>" & vbCrLf
Response.Write "<ItemID>"&rsItem("ItemID")&"</ItemID>" &
vbCrLf
Response.Write "</ItemXML>" & vbCrLf

end if
rsItem.close
set rsItem = nothing
set ItemSQL = nothing
set adoCon = nothing
%>

Build the XML using a DOM. There so many pitfuls to writing XML directly to
Response it just isn't worth it in most cases:-

<%

Dim oDOM : Set oDOM = Server.CreateObject("MSXML2.DOMDocument.3.0")
oDOM.LoadXML "<ItemXML />"

'Recordset stuff here

AddElem oDOM.documentElement, "ItemID", rsItem("ItemID")

Response.ContentType = "text/xml"
Response.CharSet = "UTF-8"
oDOM.save Response
Function AddElem(roParent, rsName, rvntValue)
Set AddElem = roParent.ownerDocument.createElement(rsName)
roParent.appendChild AddElem
If Not IsNull(rvntValue) AddElem.Text = rvntValue
End Function

%>
Apr 11 '07 #5
On Apr 11, 5:13 pm, "Anthony Jones" <A...@yadayadayada.comwrote:
<vunet...@gmail.comwrote in message

news:11**********************@q75g2000hsh.googlegr oups.com...
How to generate pure XML page with ASP?
This try gave me an error:
XML Parsing Error: not well-formed
Location:http://www.worldincatalog.com/manage....asp?itemid=15
Line Number 2, Column 26: <font face="Arial" size=2>
-------------------------^
<% @ Language="VBScript" %>
<%
Option Explicit
Response.Buffer = True
Response.ContentType = "text/xml"
' Start XML document.
Response.Write "<?xml version=""1.0""?>" & vbCrLf
%>
<!-- #Include file="adocon.inc" -->
<%
Set rsItem = Server.CreateObject("ADODB.Recordset")
ItemSQL = "...xxx..."
rsItem.Open ItemSQL, adoCon
if not rsItem.eof then
Response.Write "<ItemXML>" & vbCrLf
Response.Write "<ItemID>"&rsItem("ItemID")&"</ItemID>" &
vbCrLf
Response.Write "</ItemXML>" & vbCrLf
end if
rsItem.close
set rsItem = nothing
set ItemSQL = nothing
set adoCon = nothing
%>

Build the XML using a DOM. There so many pitfuls to writing XML directly to
Response it just isn't worth it in most cases:-

<%

Dim oDOM : Set oDOM = Server.CreateObject("MSXML2.DOMDocument.3.0")
oDOM.LoadXML "<ItemXML />"

'Recordset stuff here

AddElem oDOM.documentElement, "ItemID", rsItem("ItemID")

Response.ContentType = "text/xml"
Response.CharSet = "UTF-8"
oDOM.save Response

Function AddElem(roParent, rsName, rvntValue)
Set AddElem = roParent.ownerDocument.createElement(rsName)
roParent.appendChild AddElem
If Not IsNull(rvntValue) AddElem.Text = rvntValue
End Function

%>
this generates the output:

<ItemXML/>

What's wrong?

<% @ Language="VBScript" %>
<%
Function AddElem(roParent, rsName, rvntValue)
Set AddElem = roParent.ownerDocument.createElement(rsName)
roParent.appendChild AddElem
If Not IsNull(rvntValue) AddElem.Text = rvntValue
End Function

Dim oDOM : Set oDOM = Server.CreateObject("MSXML2.DOMDocument.
3.0")
oDOM.LoadXML "<ItemXML />"

'included adoCon
Set rsItem = Server.CreateObject("ADODB.Recordset")
ItemSQL = "SELECT * FROM TABLE WHERE ItemID = '" & request("id") &
"';"
rsItem.Open ItemSQL, adoCon
if not rsItem.eof then

AddElem oDOM.documentElement, "ItemID", rsItem("ItemID")
AddElem oDOM.documentElement, "Title", rsItem("Title")

end if
rsItem.close
set rsItem = nothing
set ItemSQL = nothing

Response.ContentType = "text/xml"
Response.CharSet = "UTF-8"
oDOM.save Response
%>

Apr 13 '07 #6

<vu******@gmail.comwrote in message
news:11*********************@b75g2000hsg.googlegro ups.com...
On Apr 11, 5:13 pm, "Anthony Jones" <A...@yadayadayada.comwrote:
<vunet...@gmail.comwrote in message

news:11**********************@q75g2000hsh.googlegr oups.com...
How to generate pure XML page with ASP?
This try gave me an error:
XML Parsing Error: not well-formed
>
Location:http://www.worldincatalog.com/manage....asp?itemid=15
Line Number 2, Column 26: <font face="Arial" size=2>
-------------------------^
<% @ Language="VBScript" %>
<%
Option Explicit
Response.Buffer = True
Response.ContentType = "text/xml"
' Start XML document.
Response.Write "<?xml version=""1.0""?>" & vbCrLf
%>
<!-- #Include file="adocon.inc" -->
<%
Set rsItem = Server.CreateObject("ADODB.Recordset")
ItemSQL = "...xxx..."
rsItem.Open ItemSQL, adoCon
if not rsItem.eof then
Response.Write "<ItemXML>" & vbCrLf
Response.Write "<ItemID>"&rsItem("ItemID")&"</ItemID>" &
vbCrLf
Response.Write "</ItemXML>" & vbCrLf
end if
rsItem.close
set rsItem = nothing
set ItemSQL = nothing
set adoCon = nothing
%>
Build the XML using a DOM. There so many pitfuls to writing XML
directly to
Response it just isn't worth it in most cases:-

<%

Dim oDOM : Set oDOM = Server.CreateObject("MSXML2.DOMDocument.3.0")
oDOM.LoadXML "<ItemXML />"

'Recordset stuff here

AddElem oDOM.documentElement, "ItemID", rsItem("ItemID")

Response.ContentType = "text/xml"
Response.CharSet = "UTF-8"
oDOM.save Response

Function AddElem(roParent, rsName, rvntValue)
Set AddElem = roParent.ownerDocument.createElement(rsName)
roParent.appendChild AddElem
If Not IsNull(rvntValue) AddElem.Text = rvntValue
End Function

%>

this generates the output:

<ItemXML/>

What's wrong?

<% @ Language="VBScript" %>
<%
Function AddElem(roParent, rsName, rvntValue)
Set AddElem = roParent.ownerDocument.createElement(rsName)
roParent.appendChild AddElem
If Not IsNull(rvntValue) AddElem.Text = rvntValue
End Function

Dim oDOM : Set oDOM = Server.CreateObject("MSXML2.DOMDocument.
3.0")
oDOM.LoadXML "<ItemXML />"

'included adoCon
Set rsItem = Server.CreateObject("ADODB.Recordset")
ItemSQL = "SELECT * FROM TABLE WHERE ItemID = '" & request("id") &
"';"
rsItem.Open ItemSQL, adoCon
if not rsItem.eof then

AddElem oDOM.documentElement, "ItemID", rsItem("ItemID")
AddElem oDOM.documentElement, "Title", rsItem("Title")
Try adding this code here:-

Else

AddElem oDOM.documentElement "Fail", "No Record for: " &
Request("id")

end if
rsItem.close
set rsItem = nothing
set ItemSQL = nothing

Response.ContentType = "text/xml"
Response.CharSet = "UTF-8"
oDOM.save Response
%>
I suspect the query isn't returning what you expect.

Also be explicit in using the Request object :- Request.QueryString("id") is
better.

I hope you will use a command object in production code. Concatenting data
from the client into a string that is executed as SQL leaves you open to SQL
injection attacks.

Use SELECT ItemID, Title instead of *.


Apr 13 '07 #7
On Apr 13, 11:30 am, "Anthony Jones" <A...@yadayadayada.comwrote:
<vunet...@gmail.comwrote in message

news:11*********************@b75g2000hsg.googlegro ups.com...On Apr 11, 5:13 pm, "Anthony Jones" <A...@yadayadayada.comwrote:
<vunet...@gmail.comwrote in message
>news:11**********************@q75g2000hsh.googleg roups.com...
How to generate pure XML page with ASP?
This try gave me an error:
XML Parsing Error: not well-formed

Location:http://www.worldincatalog.com/manage....asp?itemid=15
Line Number 2, Column 26: <font face="Arial" size=2>
-------------------------^
<% @ Language="VBScript" %>
<%
Option Explicit
Response.Buffer = True
Response.ContentType = "text/xml"
' Start XML document.
Response.Write "<?xml version=""1.0""?>" & vbCrLf
%>
<!-- #Include file="adocon.inc" -->
<%
Set rsItem = Server.CreateObject("ADODB.Recordset")
ItemSQL = "...xxx..."
rsItem.Open ItemSQL, adoCon
if not rsItem.eof then
Response.Write "<ItemXML>" & vbCrLf
Response.Write "<ItemID>"&rsItem("ItemID")&"</ItemID>" &
vbCrLf
Response.Write "</ItemXML>" & vbCrLf
end if
rsItem.close
set rsItem = nothing
set ItemSQL = nothing
set adoCon = nothing
%>
Build the XML using a DOM. There so many pitfuls to writing XML
directly to
Response it just isn't worth it in most cases:-
<%
Dim oDOM : Set oDOM = Server.CreateObject("MSXML2.DOMDocument.3.0")
oDOM.LoadXML "<ItemXML />"
'Recordset stuff here
AddElem oDOM.documentElement, "ItemID", rsItem("ItemID")
Response.ContentType = "text/xml"
Response.CharSet = "UTF-8"
oDOM.save Response
Function AddElem(roParent, rsName, rvntValue)
Set AddElem = roParent.ownerDocument.createElement(rsName)
roParent.appendChild AddElem
If Not IsNull(rvntValue) AddElem.Text = rvntValue
End Function
%>
this generates the output:
<ItemXML/>
What's wrong?
<% @ Language="VBScript" %>
<%
Function AddElem(roParent, rsName, rvntValue)
Set AddElem = roParent.ownerDocument.createElement(rsName)
roParent.appendChild AddElem
If Not IsNull(rvntValue) AddElem.Text = rvntValue
End Function
Dim oDOM : Set oDOM = Server.CreateObject("MSXML2.DOMDocument.
3.0")
oDOM.LoadXML "<ItemXML />"
'included adoCon
Set rsItem = Server.CreateObject("ADODB.Recordset")
ItemSQL = "SELECT * FROM TABLE WHERE ItemID = '" & request("id") &
"';"
rsItem.Open ItemSQL, adoCon
if not rsItem.eof then
AddElem oDOM.documentElement, "ItemID", rsItem("ItemID")
AddElem oDOM.documentElement, "Title", rsItem("Title")

Try adding this code here:-

Else

AddElem oDOM.documentElement "Fail", "No Record for: " &
Request("id")
end if
rsItem.close
set rsItem = nothing
set ItemSQL = nothing
Response.ContentType = "text/xml"
Response.CharSet = "UTF-8"
oDOM.save Response
%>

I suspect the query isn't returning what you expect.

Also be explicit in using the Request object :- Request.QueryString("id") is
better.

I hope you will use a command object in production code. Concatenting data
from the client into a string that is executed as SQL leaves you open to SQL
injection attacks.

Use SELECT ItemID, Title instead of *.
i am embarrased to say but this error happens when item does not
exist, otherwise the code works well. thank you for the hint. you are
great.

Apr 13 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: leegold2 | last post by:
I don't know how to explain this action, basically a web page will show a brief format and there'll be a link the says "show more" and when clicked more text shows. eg. goto ...
0
by: dworthem | last post by:
I am working to reverse engineer a web site (designed by a consulting firm). The site consists of predominantly asp.net pages with code behind classes. The code behind classes in general...
3
by: Olav Tollefsen | last post by:
I would like to generate a HTML page and mail it to a user. In order to design the page, I would like to leverage the Web Form designer and code-behind programming model, but instead of generating...
1
by: Rotem925 | last post by:
hello, im trying to generate and detect dtmf tones frequencies can anyone please tell me if there is ant class that handles it? or any direction where to start? i have searched the MSDN and saw...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
0
by: shukyh | last post by:
Hi all I would like to generate an HTML page from datagridview in win application (not webform). In th datagrid view I have DataGridViewCheckBoxColumn columns. How Can i do this? Thanks, Shuky
6
by: ash | last post by:
i have a web page using frameset split into few pages. And I want to generate one page of HTML code and send it through email. My question is have to generate a HTML page using asp? Thx very much.
5
by: Bjarke | last post by:
I know how to do it in vs 2003, please help!
2
by: booher | last post by:
I need help generating a PDF output where the page numbering restarts at 1 with every new chapter in a document. So the output would look something like 1-1, 1-2, 1-3,..., 2-1, 2-2, 2-3,... I'm...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.