<!--通过asp生成xml文件-->
<!--注意,这里的内容必须设置为text/xml-->
<%
response.ContentType = "text/xml"
response.Write("<?xml version = ‘1.0‘ encoding = ‘ISO-88559-1‘?>")
response.Write("<note>")
response.write("<from>John</from>")
response.Write("<to>George</to>")
response.Write("<message>Don‘t forget the meeting!</message>")
response.Write("</note>")
%>
<!--通过php生成xml文件-->
<?php
header("Content-type:text/html");
echo "<?xml version = ‘1.0‘ encoding = ‘ISO-8859-1‘?>";
echo "<note>";
echo "<from>John</from>";
echo "<to>George</to>";
echo "<message>Don‘t forget the meeting</message>";
echo "</note>";
?>
<!--从数据库获取xml-->
<%
response.ContentType = "text/xml"
set conn = Server.CreateObject("ADODB.Connection")
conn.provide = "Microsoft.Jet.OLEDB.4.0"
conn.open server.mappath("/db/database.mdb")
sql = "select FirstName, LastName from Persons"
set rs = Conn.Execute(sql)
rs.MoveFirst()
response.write("<?xml version = ‘1.0‘ encoding = ‘ISO-8859-1‘?>")
response.write(‘<Customers>‘)
while(not rs.EOF)
response.write("<Person>")
response.write("<FirstName>" & rs("FirstName") & "</FirstName>")
response.write("<LastName>" & rs("LastName") & "</LastName>")
rs.MobeNext()
wend
rs.close()
conn.close()
response.write("</Customers>")
%>
<!--通过ASP把XML保存为文件-->
<%
text = "<note>"
text = text & "<to>George</to>"
text = text & "<from>John</from>"
text = text & "<heading>Reminde</heading>"
text = text & "<body>Don‘t forget the meeting!</body>"
text = text & "</note>"
set xmlDoc = Server.CreateObject("Micsoft.XMLDOM")
xmlDoc.async = "false"
xmlDoc.loadXML(text)
xmlDoc.Save("test.xml")
%>