writeToXML.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Connection/SqlConnection.asp" -->
<%
response.Clear()
response.Charset="GB2312"
response.ContentType="text/xml"
set rs=server.CreateObject ("adodb.recordset")
rs.open "select * from affiche order by id desc",Open_conn,1,1
rs.MoveFirst()
response.write("<?xml version='1.0' encoding='GB2312'?>") 'xml格式化
response.write("<guestbook>")
while (not rs.EOF)
response.write("<guest>")
response.write("<Name>" & rs("adduser") & "</Name>")
response.write("<ID>" & rs("id") & "</ID>")
response.write("</guest>")
rs.MoveNext()
wend
rs.close
set rs=nothing
response.write("</guestbook>")
%>
核心提示:在輸出產生XML之前關鍵有下面三行代碼
response.Clear()
response.Charset="GB2312"
response.ContentType="text/xml"
然後:
<%@ page contentType="text/xml;charset=utf-8"%>然後再
<?xml version="1.0" encoding="utf-8"?>
或
<%@ page contentType="text/html;charset=utf-8"%>
就ok了,如果還不行就用notepad轉存為utf-8
如果你是ASP的話就在*.asp的開始加一行:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
這樣就能保證輸出的是utf-8了