答案:xml的资源文件
catalog.xml
<?xml version="1.0" encoding="gb2312"?>
<CATALOG>
<CD>
<TITLE>bicyle</TITLE>
<ARTIST>loveChina,我爱你中国。</ARTIST>
<COUNTRY>中国</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1982</YEAR>
</CD>
<CD>
<TITLE>bicyle</TITLE>
<ARTIST>loveChina,我爱你中国。</ARTIST>
<COUNTRY>中国</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1982</YEAR>
</CD>
</CATALOG>
catalog_html.xsl
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="' target=_blank>http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table border="1">
<tr>
<th>Title</th>
<th>Artist</th>
</tr>
<tr>
<td><xsl:value-of select="CATALOG/CD/TITLE"/></td>
<td><xsl:value-of select="CATALOG/CD/ARTIST"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
catalog_wap.xsl
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet xmlns:xsl="' target=_blank>http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<wml>
<card id="one" title="This is a first card">
<p align="center">
<xsl:value-of select="CATALOG/CD/TITLE"/><br/>
<xsl:value-of select="CATALOG/CD/ARTIST"/><br/>
中国,我爱你<br/>
bicyle.126.com<br/>
</p>
</card>
</wml>
</xsl:template>
</xsl:stylesheet>
index.asp
<%
liulanqi=request.ServerVariables("HTTP_User-Agent")
if Instr(liulanqi,"Mozilla")<>0 then
xls_use="catalog_html.xsl"
else
xls_use="catalog_wap.xsl"
Response.ContentType = "text/vnd.wap.wml"
response.Write("<?xml version='1.0' encoding='gb2312'?>")
response.Write("<!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML 1.1//EN' '")" target=_blank>http://www.wapforum.org/DTD/wml_1.1.xml'>")
end if
'Load the XML
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
xml.load(Server.MapPath("catalog.xml"))
'Load the XSL
set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load(Server.MapPath(xls_use))
'Transform the file
Response.Write(xml.transformNode(xsl))
%>
以上文件为以前学习xml后,学着编写的适合ie浏览器和手机、wap模拟器访问演示的程序代码,根据不同的设备生成两种代码。
希望大家提意见:以更好开发xml的多平台应用。
上一个:ASPX+WML开发WAP(VB版,不用MMIT)
下一个:WAP 2.0简介