服务器上生成和获取xml

前端之家收集整理的这篇文章主要介绍了服务器上生成和获取xml前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<!--通过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") %> 原文链接:/xml/297116.html

猜你在找的XML相关文章