为什么输出的 XML 文件里, 是空的?

wenjason 2002-07-03 05:02:38
我只是想将太长的标题截短来输出,但是它现在输出是空的,

<?xml version="1.0" encoding="gb2312" ?>
<News>
<Record>
<CurtTitle />
</Record>
</News>

请问怎么解决?

以下是:该 ASP 文件

<%@ Language=VBScript %>
<%set xmldoc=CreateObject("Microsoft.XMLDOM")%>
<%Response.ContentType="text/xml"%>
<?xml version="1.0" encoding="gb2312"?>

<%
maxlen="13"

Sub ShowField(strFieldName)
dim FieldMaxLen,strShow

FieldMaxLen = Cint(maxlen)
if strFieldName<>"" then
if len(strFieldName)<=FieldMaxLen then
strShow=strFieldName
else
strShow=left(strFieldName,FieldMaxLen) + "..."
end if
titlestr=strShow
end if
End Sub

set root=xmldoc.createnode("element","News","") '建立root对象
xmldoc.appendchild(root)

set news_record=xmldoc.createnode("element","Record","") '建立对象
root.appendchild(news_record) '建立节点

set curt_title=xmldoc.createnode("element","CurtTitle","")
news_record.appendchild(curt_title)
ShowField "有关B2B系统录入所填表格,域名注册,通用网址使用方法说明"
curt_title.text=titlestr

Response.Write xmldoc.xml '输出到客户端的XML
%>
...全文
26 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Zee 2002-07-03
  • 打赏
  • 举报
回复
titlestr没有在外面声明,是Sub ShowField的内部变量,外面当然取不到值。
为什么不把Sub ShowField改写成function返回titlestr呢?
MyBatis 中mapper.xml文件标签,