asp操作xml的一个非常头疼的问题。

jiaxianglei 2009-05-04 08:54:23
PaperRules.xml文件如下:
<?xml version="1.0" encoding="gb2312"?>
<root ruleCount=2>
<rule>
<bigType>电工</bigType>
<scorePerQuestion>50</scorePerQuestion>
<questionType>判断题</questionType>
<qty>2</qty>
<difficulty>不限</difficulty>
</rule>
<rule>
<bigType>电工</bigType>
<scorePerQuestion>50</scorePerQuestion>
<questionType>判断题</questionType>
<qty>2</qty>
<difficulty>不限</difficulty>
</rule>
</root>
把里面的数据转到一个字符串,格式为:
version=1 ruleCount=2 bigType0=小绞车司机 scorePerQuestion0=2 questionType0=判断题 qty0=20 difficulty0=0 bigType1=小绞车司机 scorePerQuestion1=2 questionType1=选择题 qty1=30 difficulty1=0

ruleCount为条目数,如果为3,则继续累加:bigType2...
...全文
134 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
poemGao 2009-05-06
  • 打赏
  • 举报
回复
d
jiaxianglei 2009-05-06
  • 打赏
  • 举报
回复
领导不让用数据库呀,能不能帮想想办法。
  • 打赏
  • 举报
回复
用数据库吧
jiaxianglei 2009-05-06
  • 打赏
  • 举报
回复
是不是要用到数组或XML,如何用呢,请高手指教。
jiaxianglei 2009-05-06
  • 打赏
  • 举报
回复
version=1
ruleCount=3
bigType0=焊接与热切割作业(初)
scorePerQuestion0=2
questionType0=选择题
qty0=30
difficulty0=0
bigType1=焊接与热切割作业(初)
scorePerQuestion1=2
questionType1=多选题
qty1=10
difficulty1=0
bigType2=焊接与热切割作业(初)
scorePerQuestion2=2
questionType2=判断题
qty2=10
difficulty2=0
...
这是一个备注型的字段值,如何把它分开便于从repository表中根据bigType、questionType依次查找记录,并输出结果,如何实现
jiaxianglei 2009-05-04
  • 打赏
  • 举报
回复
谢谢,我看一下。
hookee 2009-05-04
  • 打赏
  • 举报
回复
上面就是完整的呀
错误是因为你的xml是错的,不能写ruleCount=2,要写ruleCount="2"
jiaxianglei 2009-05-04
  • 打赏
  • 举报
回复
请问能贴个完整的吗?从一开始往下,因为我复制后总是出错,提示:-1072896766||应有一个字符串文字, 但找不到左引号。谢谢
hookee 2009-05-04
  • 打赏
  • 举报
回复
上面贴了一半


Set oDoc = CreateObject("Msxml2.DOMDocument")
With oDoc
.async = False
.validateOnParse = False
.preserveWhiteSpace = False
.resolveExternals = False
.load "c:\PaperRules.xml"
If .parseError.errorCode <> 0 Then
sErrMsg = .parseError.errorCode & "|" & .parseError.srcText & "|" & .parseError.reason
Set oDoc = Nothing
Response.Write sErrMsg
Response.End
End If
s = "version=1 ruleCount="
Set oNodes = .selectNodes("//rule")
s = s & oNodes.length
For i = 0 To oNodes.length - 1
Set oSubnodes = oNodes(i).selectNodes("./node()")
For j = 0 To oSubnodes.length -1
s = s & oSubnodes(j).tagName & i & "=" & oSubnodes(j).text & " "
Next
Set oSubnodes = Nothing
Next
Set oNodes = Nothing
Response.Write s
End With
Set oDoc = Nothing
hookee 2009-05-04
  • 打赏
  • 举报
回复

Set oDoc = Nothing
Response.Write sErrMsg
Response.End
End If
s = "version=1 ruleCount="
Set oNodes = .selectNodes("//rule")
s = s & oNodes.length
For i = 0 To oNodes.length - 1
Set oSubnodes = oNodes(i).selectNodes("./node()")
For j = 0 To oSubnodes.length -1
s = s & oSubnodes(j).tagName & i & "=" & oSubnodes(j).text & " "
Next
Set oSubnodes = Nothing
Next
Set oNodes = Nothing
Response.Write s
End With
Set oDoc = Nothing

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧