·þÎñÆ÷É쵀 XML
XML ÎļþÊÇÀàËÆ HTML ÎļþµÄ´¿Îı¾Îļþ¡£
Äܹ»Í¨¹ý±ê×¼µÄ web ·þÎñÆ÷ÇáËɵش洢ºÍÉú³É XML¡£
ÔÚ·þÎñÆ÷ÉÏ´æ´¢ XML
XML ÎļþÔÚ Internet ·þÎñÆ÷ÉϽøÐд洢µÄ·½Ê½Óë HTML ÎļþÍêÈ«Ïàͬ¡£
Çë´ò¿ª Windows ¼Çʱ¾£¬²¢ÊäÈëÒÔÏ´úÂ룺
<?xml version="1.0" encoding="ISO-8859-1"?> <note> <from>John</from> <to>George</to> <message>Don't forget the meeting!</message> </note>
È»ºóÓÃÊʵ±µÄÎļþÃû£¬±ÈÈç "note.xml"£¬ÔÚ web ·þÎñÆ÷Éϱ£´æÕâ¸öÎļþ¡£
ͨ¹ý ASP Éú³É XML
XML ¿ÉÔÚ²»°²×°ÈκΠXML Èí¼þµÄÇé¿öÏÂÔÚ·þÎñÆ÷¶ËÉú³É¡£
ÈçÐè´Ó·þÎñÆ÷Éú³É XML ÏìÓ¦ - Ö»Ðè¼òµ¥µØ±àдÒÔÏ´úÂë²¢ÔÚ·þÎñÆ÷ÉϰÑËü±£´æÎªÒ»¸ö ASP Îļþ£º
<%
response.ContentType="text/xml"
response.Write("<?xml version='1.0' encoding='ISO-8859-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>")
%>
Çë×¢Ò⣬´ËÏìÓ¦µÄÄÚÈÝÀàÐͱØÐëÉèÖÃΪ "text/xml"¡£
²é¿´Õâ¸öASPÎļþÈçºÎ´Ó·þÎñÆ÷·µ»Ø
Èç¹ûÄú»¹²»¶®ÈçºÎ±àд ASP£¬Çë·ÃÎÊÎÒÃǵġ¶ASP ½Ì³Ì¡·¡£
ͨ¹ý PHP Éú³É XML
ÈçÐèʹÓà PHP ÔÚ·þÎñÆ÷ÉÏÉú³É XML ÏìÓ¦£¬ÇëʹÓÃÏÂÃæµÄ´úÂ룺
<?php
header("Content-type:text/xml");
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>";
?>
Çë×¢Ò⣬ÏìӦͷ²¿µÄÄÚÈÝÀàÐͱØÐëÉèÖÃΪ "text/xml"¡£
Èç¹ûÄúÐèҪѧϰ PHP£¬Çë·ÃÎÊÎÒÃǵġ¶PHP ½Ì³Ì¡·¡£
´ÓÊý¾Ý¿â»ñÈ¡ XML
XML ¿ÉÔÚ²»°²×°ÈκΠXML Èí¼þµÄÇé¿öÏ´ÓÊý¾Ý¿âÉú³É¡£
ÈçÐè´Ó·þÎñÆ÷Éú³É XML Êý¾Ý¿âÏìÓ¦£¬Ö»Ðè¼òµ¥µØ±àдÒÔÏ´úÂ룬²¢°ÑËüÔÚ·þÎñÆ÷Éϱ£´æÎª ASP Îļþ£º
<% response.ContentType = "text/xml" set conn=Server.CreateObject("ADODB.Connection") conn.provider="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>") response.write("</Person>") rs.MoveNext() wend rs.close() conn.close() response.write("</Customers>") %>
²é¿´ÒÔÉÏ ASP ´úÂëµÄʵ¼ÊÊý¾Ý¿âÊä³ö°¸Àý
ÉÏÃæµÄÀý×ÓʹÓÃÁË´øÓÐ ADO µÄ ASP¡£
Èç¹ûÄúÐèҪѧϰ ADO£¬Çë·ÃÎÊÎÒÃǵġ¶ADO ½Ì³Ì¡·¡£
ÔÚ·þÎñÆ÷ÉÏͨ¹ý XSLT ת»» XML
ÏÂÃæµÄ ASP ´úÂëÔÚ·þÎñÆ÷É졄 XML Îļþת»»Îª XHTML£º
<% 'Load XML set xml = Server.CreateObject("Microsoft.XMLDOM") xml.async = false xml.load(Server.MapPath("simple.xml")) 'Load XSL set xsl = Server.CreateObject("Microsoft.XMLDOM") xsl.async = false xsl.load(Server.MapPath("simple.xsl")) 'Transform file Response.Write(xml.transformNode(xsl)) %>
Àý×Ó½âÊÍ
- µÚÒ»¸ö´úÂë¿é´´½¨Î¢Èí XML ½âÎöÆ÷µÄʵÀý (XMLDOM)£¬²¢°Ñ XML ÎļþÔØÈëÄÚ´æ
- µÚ¶þ¸ö´úÂë¿é´´½¨½âÎöÆ÷µÄÁíÒ»¸öʵÀý£¬²¢°Ñ XSL ÎļþÔØÈëÄÚ´æ
- ×îºóÒ»¸ö´úÂëʹÓà XSL ÎĵµÀ´×ª»» XML Îĵµ£¬²¢°Ñ½á¹ûÒÔ XHTML ·¢Ë͵½ÄúµÄä¯ÀÀÆ÷¡£Í깤¡£
ͨ¹ý ASP °Ñ XML ±£´æÎªÎļþ
Õâ¸ö ASP ʵÀý»á´´½¨Ò»¸ö¼òµ¥µÄ XML Îĵµ£¬²¢°Ñ¸ÃÎĵµ±£´æµ½·þÎñÆ÷ÉÏ£º
<% text="<note>" text=text & "<to>George</to>" text=text & "<from>John</from>" text=text & "<heading>Reminder</heading>" text=text & "<body>Don't forget the meeting!</body>" text=text & "</note>" set xmlDoc=Server.CreateObject("Microsoft.XMLDOM") xmlDoc.async="false" xmlDoc.loadXML(text) xmlDoc.Save("test.xml") %>