日期:2014-05-17  浏览次数:21164 次

asp 如何在XML 中写动态代码...急
网站首页中有一个图片轮播的JS,其中有一个XML文件控制图片的路径、图片文件名称、跳转地址等。我想在XML中添加动态代码,在后台可以控制图片文件路径等信息。不知道是否可行,或者有什么别的方法可以决解,求各位大侠帮忙...以下是XML文件代码:
XML code

<?xml version="1.0" encoding="UTF-8"?>

<!-- slideShowTime - if set to 0, there is no autoslide -->

<banner width = "988" height = "300"
        backgroundColor = "0xffffff"
        backgroundTransparency = "100"
        
        startWith = "1"
        barHeight = "28"
        fadeTransition = "false"
        verticalTransition = "false"
        controllerTop = "false"
        transitionSpeed = "1"
        titleX = "0"
        titleY = "0">

    <items>
        <item>
            <title></title>
            <path>images/01.jpg</path>
            <url>http://www.lanrentuku.com/</url>
            <target>_blank</target>
            <bar_color>0x4A5E33</bar_color>
            <bar_transparency>50</bar_transparency>
            <slideShowTime>3</slideShowTime>
        </item>
        <item>
            <title></title>
            <path>images/02.jpg</path>
            <url>http://www.lanrentuku.com/</url>
            <target>_blank</target>
            <bar_color>0x2075c4</bar_color>
            <bar_transparency>50</bar_transparency>
            <slideShowTime>3</slideShowTime>
        </item>
            
    </items>
        
</banner>





------解决方案--------------------
VBScript code
<!--#include file="Conn_1.asp"-->

<%
XmlStr ="<?xml version=""1.0"" encoding=""UTF-8""?>"
XmlStr =XmlStr&"<banner width = ""988"" height = ""300"""
XmlStr =XmlStr&"backgroundColor = ""0xffffff"""
XmlStr =XmlStr&" backgroundTransparency = ""100"""
        
XmlStr =XmlStr&" startWith = ""1"""
XmlStr =XmlStr&"barHeight = ""28"""
XmlStr =XmlStr&"fadeTransition = ""false"""
XmlStr =XmlStr&"verticalTransition = ""false"""
XmlStr =XmlStr&"controllerTop = ""false"""
XmlStr =XmlStr&"transitionSpeed = ""1"""
XmlStr =XmlStr&"titleX = ""0"""
XmlStr =XmlStr&"titleY = ""0"">"



    XmlStr =XmlStr&"<items>"
    set rs=server.CreateObject("adodb.recordset")
sql="select top 6 * from adv where ad_type=0 order by id asc"
rs.open sql,conn,1,1
if not rs.eof and not rs.bof then
do while not rs.eof
        XmlStr = XmlStr + "<item>"
         XmlStr = XmlStr + "<title>"&rs(..)&"</title>"
           XmlStr = XmlStr + "<path>images/01.jpg</path>"
            XmlStr = XmlStr + "<url>http://www.lanrentuku.com/</url>"
            XmlStr = XmlStr + "<target>_blank</target>"
            XmlStr = XmlStr + "<bar_color>0x4A5E33</bar_color>"
            XmlStr = XmlStr + "<bar_transparency>50</bar_transparency>"
            XmlStr = XmlStr + "<slideShowTime>3</slideShowTime>"
         XmlStr = XmlStr + "</item>"
        rs.movenext
        ne