ÍøÂçѧԺ w3popÉçÇø ÍøÂç×ÊÔ´ ITÐÂÎÅ

w3pop.com :: ÍøÂçѧԺ :: XML :: XML ·þÎñÆ÷

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

Íü¼ÇÃÜÂë? ×¢²á

XML
XML ½éÉÜ
XML µÄÓÃ;
XML Óï·¨¹æÔò
XML ÔªËØ
XML ÊôÐÔ
XML µÄÓÐЧÐÔÑéÖ¤
XML УÑéÆ÷
Ö§³Ö XML µÄä¯ÀÀÆ..
ä¯ÀÀ XML Îļþ
Óà CSS ÏÔʾ XML
Óà XSL ÏÔʾ XML
XML Êý¾Ýµº
XML ½âÎöÆ÷
ÏÖʵÖÐµÄ XML
XML ÃüÃû¿Õ¼ä
XML CDATA
XML ·þÎñÆ÷
XML Ó¦ÓóÌÐò
XMLHttpRequest ¶..
XML ±£´æÊý¾Ý

XML ·þÎñÆ÷


×÷Õß:w3pop.com ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-29 ÐÞ¸Ä:2007-08-15 ä¯ÀÀ:4830 :: ::

XML can be generated on a server without installing any XML controls.
ÎÞÐë°²×°ÈκÎXML¿Ø¼þ¾Í¿ÉÒÔÔÚ·þÎñÆ÷ÉÏÉú³ÉXMLÎļþ¡£


Storing XML on the Server
ÔÚ·þÎñÆ÷ÉÏ´¢´æxml

XML files can be stored on an Internet server exactly the same way as HTML files.
XMLÎļþÔÚInternet ·þÎñÆ÷ÉϵĴ¢´æ·½Ê½ÓëHTMLÎļþÍêÈ«Ïàͬ¡£

Start Windows Notepad and write the following lines:
´ò¿ªWindows ¼Çʱ¾£¬²¢ÊéдÏÂÃæµÄ´úÂ룺

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

<note>
<from>Jani</from>
<to>Tove</to>
<message>Remember me this weekend</message>

</note>

Save the file on your web server with a proper name like "note.xml".
¸øÎļþÆð¸öÇ¡µ±µÄÃû×Ö£¨È磺note.xml£©£¬²¢½«Æä±£´æÔÚÍøÂç·þÎñÆ÷ÉÏ¡£


Generating XML with ASP
ÀûÓÃASPÉú³ÉXML

XML can be generated on a server without any installed XML software.
ÎÞÐë°²×°ÈκÎXMLÈí¼þ¾Í¿ÉÒÔÔÚ·þÎñÆ÷ÉÏÉú³ÉXML¡£

To generate an XML response from the server - simply write the following code and save it as an ASP file on the web server:
ΪÁËÔÚ·þÎñÆ÷¶Ë²úÉúÒ»¸öXMLÏìÓ¦——Ö»Ðë¼òµ¥Ð´ÏÂÈçϵĴúÂ룬²¢ÔÚÍøÂç·þÎñÆ÷ÉϰÑËü±£´æÎªÒ»·ÝASPÎļþ

<%
response.ContentType="text/xml"

response.Write("<?xml version='1.0' encoding='ISO-8859-1'?>")
response.Write("<note>")
response.Write("<from>Jani</from>")
response.Write("<to>Tove</to>")
response.Write("<message>Remember me this weekend</message>")
response.Write("</note>")
%>

Note that the content type of the response must be set to "text/xml".
×¢Òâ»Ø¸´µÄÄÚÈÝÀàÐͱØÐëÉèÖÃΪ"text/xml"¡£

See how the ASP file will be returned from the server.
¿´¿´´Ó·þÎñÆ÷·µ»ØµÄASPÎļþÀïÓÐЩʲô.

If you don't know how to write ASP, please visit our ASP tutorial
Èç¹ûÄã²»ÖªµÀÔõôдASP,¿ÉÒÔ·ÃÎÊÎÒÃÇµÄ ASP½Ì³Ì


Getting XML From a Database
´ÓÊý¾Ý¿âµÃµ½XMLÐÎʽÊý¾Ý

XML can be generated from a database without any installed XML software.
ûÓа²×°ÈκÎXMLÈí¼þ¾Í¿ÉÒÔ´ÓÊý¾Ý¿âÖвúÉúXML¡£

To generate an XML database response from the server, simply write the following code and save it as an ASP file on the web server:
ΪÁË´Ó·þÎñÆ÷µÃµ½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 fname,lname from tblGuestBook"
set rs=Conn.Execute(sql)
rs.MoveFirst()
response.write("<?xml version='1.0' encoding='ISO-8859-1'?>")
response.write("<guestbook>")
while (not rs.EOF)
response.write("<guest>")
response.write("<fname>" & rs("fname") & "</fname>")
response.write("<lname>" & rs("lname") & "</lname>")
response.write("</guest>")
rs.MoveNext()
wend
rs.close()
conn.close()
response.write("</guestbook>")
%>

See the real life database output from the ASP file above.
¿´¿´ÉÏÊöASPÎļþÖеÄÊý¾Ý¿âµÄʵ¼ÊÊä³öÇé¿ö.

The example above uses ASP with ADO. If you don't know how to use ADO, please visit our ADO tutorial.
ÉÏÊöµÄ°¸ÀýʹÓÃÁËASP£¬²¢ÔÚASPÖÐÔËÓÃÁËADO¡£Èç¹ûÄã¶ÔADOµÄÓ÷¨»¹²»Á˽⣬¿ÉÒÔ²éÔÄÎÒÃÇµÄ ADO ½Ì³Ì¡£

ÆÀÂÛ (0) All