以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 XML 与 数据库 』  (http://bbs.xml.org.cn/list.asp?boardid=17)
----  [求助]如何方断数据空时怎么写进xml  (http://bbs.xml.org.cn/dispbbs.asp?boardid=17&rootid=&id=36357)


--  作者:yuhuan
--  发布时间:8/3/2006 4:02:00 PM

--  [求助]如何方断数据空时怎么写进xml
这个是生成xml的代码

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>xml</title>
</head>
<body>
<%
Sql = "select top 20 * from sample order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
Set facXmlDocument = Server.CreateObject("Msxml2.DOMDocument")
facXmlDocument.Load Server.MapPath("data.xml")
facXmlDocument.LoadXML("<data />")
do While Not Rs.EOF
Set Node = facXmlDocument.createElement("products")
 Node.setAttribute "id", int(Rs("id"))
 Node.setAttribute "time", Rs("time")
 Node.setAttribute "RootID", Rs("RootID")
 Node.setAttribute "SortID", Rs("SortID")
 Node.setAttribute "upload", Rs("upload")
 Node.setAttribute "download", Rs("download")
 Node.setAttribute "datetime", Rs("datetime")
 Node.setAttribute "csnumber", Rs("csnumber")
 Node.setAttribute "ypnumber", Rs("ypnumber")
 if Rs("barmark")="" then
 Node.setAttribute "barmark", ""
 else
 Node.setAttribute "barmark", Rs("barmark")
 end if
 Node.setAttribute "chname", Rs("chname")
 if Rs("engname")="" then
 Node.setAttribute "engname", ""
 else
 Node.setAttribute "engname", Rs("engname")
 end if
 Node.setAttribute "classnum", Rs("classnum")
 if Rs("bigclass")="" then
 Node.setAttribute "bigclass", ""
 else
 Node.setAttribute "bigclass", Rs("bigclass")
 end if
 if Rs("classname")="" then
 Node.setAttribute "classname", ""
 else
 Node.setAttribute "classname", Rs("classname")
 end if
 Node.setAttribute "casingmode", Rs("casingmode")
 if Rs("package")="" then
 Node.setAttribute "package", ""
 else
 Node.setAttribute "package", Rs("package")
 end if
 if Rs("engunit")="" then
 Node.setAttribute "engunit", ""
 else
 Node.setAttribute "engunit", Rs("engunit")
 end if
 if Rs("unitname")="" then
 Node.setAttribute "unitname", ""
 else
 Node.setAttribute "unitname", Rs("unitname")
 end if
 Node.setAttribute "yplong", Rs("yplong")
 Node.setAttribute "ypwidth", Rs("ypwidth")
 Node.setAttribute "yphigh", Rs("yphigh")
 if Rs("remarks")="" then
 Node.setAttribute "remarks", ""
 else
 Node.setAttribute "remarks", Rs("remarks")
 end if
 Node.setAttribute "casinglong", Rs("casinglong")
 Node.setAttribute "casingwidth", Rs("casingwidth")
 Node.setAttribute "casinghigh", Rs("casinghigh")
 if Rs("cubage")="" then
 Node.setAttribute "cubage", ""
 else
 Node.setAttribute "cubage", Rs("cubage")
 end if
 Node.setAttribute "datum", Rs("datum")
 Node.setAttribute "wxidate", Rs("wxidate")
 Node.setAttribute "wxamount", Rs("wxamount")
 Node.setAttribute "wxlh", Rs("wxlh")
 Node.setAttribute "wxds", Rs("wxds")
 Node.setAttribute "wxmz", Rs("wxmz")
 Node.setAttribute "wxjz", Rs("wxjz")
 Node.setAttribute "wxndate", Rs("wxndate")
 Node.setAttribute "wxdj", Rs("wxdj")
 Node.setAttribute "wxsj", Rs("wxsj")
 Node.setAttribute "wxlow", Rs("wxlow")
 Node.setAttribute "wxconvert", Rs("wxconvert")
 if Rs("nxamount")="" then
 Node.setAttribute "nxamount", ""
 else
 Node.setAttribute "nxamount", Rs("nxamount")
 end if
 if Rs("nxmxsl")="" then
 Node.setAttribute "nxmxsl", ""
 else
 Node.setAttribute "nxmxsl", Rs("nxmxsl")
 end if
 if Rs("nxlhsl")="" then
 Node.setAttribute "nxlhsl", ""
 else
 Node.setAttribute "nxlhsl", Rs("nxlhsl")
 end if
 if Rs("flash")="" then
 Node.setAttribute "flash", ""
 else
 Node.setAttribute "flash", Rs("flash")
 end if
 Node.setAttribute "smallimg", Rs("smallimg")
 Node.setAttribute "bigimage", Rs("bigimage")
 if Rs("nxcj")="" then
 Node.setAttribute "nxcj", ""
    else
 Node.setAttribute "nxcj", Rs("nxcj")
 end if
 if Rs("nxdj")="" then
 Node.setAttribute "nxdj", ""
 else
 Node.setAttribute "nxdj", Rs("nxdj")
 end if
 if Rs("nxsj")="" then
 Node.setAttribute "nxsj", ""
 else
 Node.setAttribute "nxsj", Rs("nxsj")
 end if
 if Rs("nxlow")="" then
 Node.setAttribute "nxlow", ""
 else
 Node.setAttribute "nxlow", Rs("nxlow")
 end if
 if Rs("nxidate")="" then
 Node.setAttribute "nxidate", ""
 else
 Node.setAttribute "nxidate", Rs("nxidate")
 end if
 if Rs("nxndate")="" then
 Node.setAttribute "nxndate", ""
 else
 Node.setAttribute "nxndate", Rs("nxndate")
 end if
 if Rs("discount")="" then
 Node.setAttribute "discount", ""
 else
 Node.setAttribute "discount", Rs("discount")
 end if
 if Rs("frequency")="" then
 Node.setAttribute "frequency", ""
 else
 Node.setAttribute "frequency", Rs("frequency")
 end if
 facXmlDocument.documentElement.appendChild(Node)
Rs.MoveNext
loop
Rs.Close
set Rs = nothing
conn.close
set conn=nothing
facXmlDocument.Save server.MapPath("data.xml")
set facXmlDocument=nothing
%>
</body>

</html>

生成的xml是这样

- <data>
  <products id="83445" time="59078" RootID="00001" SortID="00002" upload="0" download="0" csnumber="01286" ypnumber="BT89642" barmark="" chname="电动童车" engname="" classnum="0101" casingmode="彩盒" package="PRINTED BOX" engunit="PC" unitname="只" yplong="0" ypwidth="0" yphigh="0" remarks="" casinglong="90" casingwidth="50" casinghigh="57" cubage="0.257" datum="9.077" wxidate="2006-07-31" wxamount="1" wxlh="0" wxds="0" wxmz="14.7" wxjz="12" wxndate="2006-07-31" wxdj="0" wxsj="0" wxlow="0" wxconvert="0" smallimg="Loadimg/BT89000/BT89642.jpg" bigimage="Loadimg/BT89000/BT89642.jpg" />
<products id="5363" time="63670" RootID="00071" SortID="00077" upload="0" download="0" datetime="2004-07-13 14:12:22" csnumber="01309" ypnumber="BT00001" barmark="" chname="玩具枪(银)" engname="" classnum="1199" classname="其它枪类" casingmode="OPP袋" package="OPP Bag" engunit="PC" unitname="只" yplong="16" ypwidth="11.5" yphigh="3" remarks="" casinglong="62.5" casingwidth="30.5" casinghigh="45" cubage="0.08578125" datum="3.02979375" wxidate="2004-07-13" wxamount="180" wxlh="0" wxds="15" wxmz="23" wxjz="21" wxndate="2004-07-13" wxdj="0" wxsj="0" wxlow="0" wxconvert="0" nxamount="0" nxmxsl="0" nxlhsl="0" smallimg="Loadimg/BT00000/BT00001.jpg" bigimage="Loadimg/BT00000/BT00001.jpg" nxcj="0" nxdj="0" nxsj="0" nxlow="0" nxidate="2004-07-13" nxndate="2004-07-13" discount="0" />
</data>


生成的xml中  怎么
nxcj="0" nxdj="0" nxsj="0" nxlow="0" nxidate="2004-07-13" nxndate="2004-07-13" discount="0"

这段数据有的有显示有的不可以显示

是不是没判断是不是为null数据的结果~~


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
78.125ms