We help IT Professionals succeed at work.

Create a XML Document using an ASP

Moony
Moony asked
on
I am in trouble trying to create a XML Document using an ASP file

I am trying to get this simple XML file:
"
<?xml version="1.0"?>
<data><![CDATA[i]]></data>
"

Well... I write this code in ASP:

"
<% @language=VBScript%>
<%
Response.ContentType = "text/xml"
%>

<%
     response.write "<?xml version=""1.0""?>" & vbCrLf
     Response.write "<dat>"
     response.write "<![CDATA[i]]>"
     response.write "</dat>"
%>
"

and I get the following error message :

"
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

An invalid character was found in text content. Error processing resource 'http://localhost/file001.asp'. Line 2, Position 15
 

<dat><![CDATA[
"

If I specify the codepage for the page:
"
<% @language=VBScript% @codepage=65001>
<%
Response.ContentType = "text/xml"
%>

<%
     response.write "<?xml version=""1.0""?>" & vbCrLf
     Response.write "<dat>"
     response.write "<![CDATA[i]]>"
     response.write "</dat>"
%>

then I get a different error :
"
 <font face="Arial" size=2>
<p>Active Server Pages</font> <font face="Arial" size=2>error 'ASP 0203'</font>
<p>
<font face="Arial" size=2>Invalid Code Page</font>
<p>
<font face="Arial" size=2>/prueba.asp</font><font face="Arial" size=2>, line 1</font>
<p>
<font face="Arial" size=2>The specified code page attribute is invalid.
</font>
"

The ASP file is running under NT workstation 4.0 (service pack 6a) and the last Option Pack(with PWS). Should I upgrade to Windows 2000 to be able to generate XML from ASP? Or maybe install the IIS 4.0...

Thanks in advanced

Comment
Watch Question

Hey,
Did you try taking out the 'i'?
<%
    response.write "<?xml version=""1.0""?>" & vbCrLf
    Response.write "<dat>"
    response.write "<![CDATA[]]>"
    response.write "</dat>"
%>
and also at the top you wrote <data>, but then you write <dat>. Try to be consistent.
:)

Author

Commented:
Well, I wrote this message because the problem is "i". I know if I try to write another thing it works but it doesnt with "i" or "a" or "e"...

And I am consistent...the example was it and the ASP too...

Commented:
There is nothing wrong with your code at all.. you are using an older version of the browser.  Update to IE 5.5 sp2 or higher.  the parser your version of IE does not understand the code its recieving... this should fix your problem.
dware,

Please dont lock questions, if user feel your answer satisfactory or if he want he will select your comment as answer.

bye
Vijay
Proposed answer rejected.

Netminder
CS Moderator
Commented:
The actual ASP file is probebly ANSI encoded but the output "file" must be UTF-8.

I'd keep the ANSI coding and write :-

<?xml version="1.0" encoding="iso-8859-1"?>


(You don't then need the codepage=65001 since it's not a UTF-8 document.)

PS: Why the CDATA section?
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
[Accept BigRat's comment as answer
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
>S'Plug<
EE Cleanup Volunteer

Explore More ContentExplore courses, solutions, and other research materials related to this topic.