| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 725 人关注过本帖
标题:求救!help!(asp生成XML)问题....高手请进!!!
只看楼主 加入收藏
jasonhahad
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-10-19
收藏
 问题点数:0 回复次数:2 
求救!help!(asp生成XML)问题....高手请进!!!
我做了个asp生XML的页面问题如下.
当这样写
<%
xmlfile=server.mappath("pantechs.xml")
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile(xmlfile,True)
MyFile.WriteLine("<?xml version=""1.0"" encoding=""gb2312""?>")
MyFile.WriteLine("<topcategories>")
'一级目录生成
Call Left_Categories
Sub Left_Categories
dim Color,Color2,CSS,CSS2
dim prs2
rs.Open "select * from shop_anclass  order by  anclassidorder  ",conn,1,1
do while not rs.eof
set prs2=conn.execute("select * from shop_nclass where anclassid="&rs("anclassid")&"  order by  nclassidorder")
MyFile.WriteLine("<topcategory id="""&""&rs("anclassid")&""&""" name="""&""&rs("anclass")&""&""">")

'二级目录生成
if not prs2.eof then
do while not prs2.eof
MyFile.WriteLine("<category id="""&""&prs2("nclassid")&""&""" name="""&""&prs2("nclass")&""&""">")

'产品生成
'产品生成完毕

MyFile.WriteLine("</category>")
'二级目录生成完毕
'一级目录生成完毕


prs2.movenext
    loop
    end if
  prs2.close
  set prs2=nothing
  MyFile.WriteLine("</topcategory>")
  
rs.movenext
loop
rs.close
End sub

'生成完毕
MyFile.WriteLine("<imagebase>/</imagebase>")
MyFile.WriteLine("</topcategories>")

pidone=""  
pid=int(request("pid"))                    
pid2=int(request("pid2"))
pidone=pid
if pid<>""  then
c="where  anclassid="&pid&" "
end if                  
if pid2<>"" and  pid2<>0  then
d="  and nclassid="&pid2
end if
pname2=trim(Request("word"))
if pname2<>"" then
c="where  SMT_cpname like  '%"&pname2&"%' "
end if
id=request("id")
if id<>""  then
c="where SMT_sortid="&id&" "
end if
if request("sale")="sale" then
c="where SMT_newsbook=1 "
end if
set vrs=server.createobject("adodb.recordset")
if  pidone<>"" and pidone<>0 then
vrs.open "select * from SMT_cp  "&c&"  "&d&"  order by  top, SMT_cpname  ",conn,1,1        
elseif pname2<>"" then
vrs.open "select * from SMT_cp   "&c&"  order by  top ",conn,1,1
else
vrs.open "select * from SMT_cp   order by  top ",conn,1,1
end if
if vrs.recordcount=0 then
'fuck
else
iCount=rs.RecordCount'记录总数
iPageSize=rs.PageSize
maxpage=rs.pageCount
page=request("page")
vrs.AbsolutePage=Page
x=iPageSize
For vdssi=1 To x            
if vrs.EOF or vrs.BOF then exit for
id=request("id")
MyFile.WriteLine("<ionttt id="""&""&vrs("SMT_id")&""&""" name="""&""&vrs("SMT_cpname")&""&""">")
MyFile.WriteLine("</ionttt>")
vrs.movenext
next
end if
vrs.close
set vrs=nothing

MyFile.Close

%>
的时候会生成

<?xml version="1.0" encoding="gb2312"?>
<topcategories>
<topcategory id="76" name="我是1">
<category id="456" name="我是小1c">
</category>
<category id="453" name="我是小1a">
</category>
<category id="455" name="我是小1b">
</category>
</topcategory>
<topcategory id="78" name="我是3">
</topcategory>
<topcategory id="77" name="我是2">
</topcategory>
<topcategory id="83" name="我是4">
<category id="454" name="ssssssssssdfsdf">
</category>
</topcategory>
<imagebase>/</imagebase>
</topcategories>
<ionttt id="714" name="B05-710.02">
</ionttt>
<ionttt id="713" name="B02-37902">
</ionttt>



当这样写

<!--#include file="inc/conn.asp"-->
<%



xmlfile=server.mappath("pantechs.xml")
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile(xmlfile,True)
MyFile.WriteLine("<?xml version=""1.0"" encoding=""gb2312""?>")
MyFile.WriteLine("<topcategories>")
'一级目录生成
Call Left_Categories
Sub Left_Categories
dim Color,Color2,CSS,CSS2
dim prs2
rs.Open "select * from shop_anclass  order by  anclassidorder  ",conn,1,1
do while not rs.eof
set prs2=conn.execute("select * from shop_nclass where anclassid="&rs("anclassid")&"  order by  nclassidorder")
MyFile.WriteLine("<topcategory id="""&""&rs("anclassid")&""&""" name="""&""&rs("anclass")&""&""">")

'二级目录生成
if not prs2.eof then
do while not prs2.eof
MyFile.WriteLine("<category id="""&""&prs2("nclassid")&""&""" name="""&""&prs2("nclass")&""&""">")

'产品生成
pidone=""  
pid=int(request("pid"))                    
pid2=int(request("pid2"))
pidone=pid
if pid<>""  then
c="where  anclassid="&pid&" "
end if                  
if pid2<>"" and  pid2<>0  then
d="  and nclassid="&pid2
end if
pname2=trim(Request("word"))
if pname2<>"" then
c="where  SMT_cpname like  '%"&pname2&"%' "
end if
id=request("id")
if id<>""  then
c="where SMT_sortid="&id&" "
end if
if request("sale")="sale" then
c="where SMT_newsbook=1 "
end if
set vrs=server.createobject("adodb.recordset")
if  pidone<>"" and pidone<>0 then
vrs.open "select * from SMT_cp  "&c&"  "&d&"  order by  top, SMT_cpname  ",conn,1,1        
elseif pname2<>"" then
vrs.open "select * from SMT_cp   "&c&"  order by  top ",conn,1,1
else
vrs.open "select * from SMT_cp   order by  top ",conn,1,1
end if
if vrs.recordcount=0 then
'fuck
else
iCount=rs.RecordCount'记录总数
iPageSize=rs.PageSize
maxpage=rs.pageCount
page=request("page")
vrs.AbsolutePage=Page
x=iPageSize
For vdssi=1 To x            
if vrs.EOF or vrs.BOF then exit for
id=request("id")
MyFile.WriteLine("<ionttt id="""&""&vrs("SMT_id")&""&""" name="""&""&vrs("SMT_cpname")&""&""">")
MyFile.WriteLine("</ionttt>")
vrs.movenext
next
end if
vrs.close
set vrs=nothing
'产品生成完毕

MyFile.WriteLine("</category>")
'二级目录生成完毕
'一级目录生成完毕


prs2.movenext
    loop
    end if
  prs2.close
  set prs2=nothing
  MyFile.WriteLine("</topcategory>")
  
rs.movenext
loop
rs.close
End sub



'生成完毕
MyFile.WriteLine("<imagebase>/</imagebase>")
MyFile.WriteLine("</topcategories>")








MyFile.Close

%>
 

的时候就出错,只能显示
<?xml version="1.0" encoding="gb2312"?>
<topcategories>
<topcategory id="76" name="我是1">
<category id="456" name="我是小1c">
<imagebase>/</imagebase>
</topcategories>
就没有了.
我不知道是不是嵌套循环的时候出错.
我对asp不是很熟悉.清高手指点迷津
搜索更多相关主题的帖子: XML help asp 
2008-10-19 16:20
jasonhahad
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-10-19
收藏
得分:0 
注:<!--#include file="inc/conn.asp"-->其实两次都有写的.只是弟一次复制少了..没办法改.
2008-10-19 16:27
sunfishy
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:311
专家分:163
注 册:2007-6-29
收藏
得分:0 
代码多.帮顶.
2008-10-19 16:28
快速回复:求救!help!(asp生成XML)问题....高手请进!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016293 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved