VBS读取xml的问题

shanyuhuang shanyuhuang 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
本人小白,不太了解xml,vba也只是略懂,现有下面的课题,望各位大神不吝赐教

现有客户如下VBS代码:
根据输入参数:pIn01,pIn02,pIn03分别设置输出参数pOut01,pOut02,pOut01

Select Case pIn01
Case "A01" :
If pIn02 = 0 Then
If pIn03 = 2 Then
pOut01 = "X01"
pOut02 = "Y01"
pOut03 = 0
Else
pOut03 = 1
End If
Else
pOut03 = 2
End If

Case "B01" :
If pIn02 = 1 Then
If pIn03 = 3 Then
pOut01 = "X02"
pOut02 = "Y02"
pOut03 = 0
Else
pOut03 = 1
End If
Else
pOut03 = 2
End If

Case "C01" :
If pIn02 = 0 Then
If pIn03 = 3 Or pIn03 = 4 Then
pOut01 = "X03"
pOut02 = "Y03"
pOut03 = 0
Else
pOut03 = 1
End If
Else
pOut03 = 2
End If

Case "D01" :
If pIn02 = 0 Then
If pIn03 = 2 Then
pOut01 = "X04"
pOut02 = "Y04"
pOut03 = 0
Else
pOut03 = 1
End If
Else
If pIn03 = 4 Then
pOut01 = "X05"
pOut02 = "Y05"
pOut03 = 0
Else
pOut03 = 1
End If
End If

Case "E01" :
If pIn02 = 0 Then
pOut03 = 2
Else
If pIn03 = 4 Then
pOut01 = "X06"
pOut02 = "Y06"
pOut03 = 0
Else
pOut03 = 1
End If
End If

Case "F01" :
If pIn02 = 0 Then
If pIn03 = 3 Then
If pIn04 = "NAME01" Then
pOut01 = "X07"
pOut02 = "Y07"
pOut03 = 0
ELSE
pOut01 = "X08"
pOut02 = "Y08"
pOut03 = 0
END IF
Else
pOut03 = 1
End If
Else
pOut03 = 2
End If

Case Else :
pOut03 = 2
End Select


现在客户觉得这种写法太傻,希望把这个对应关系以xml形式保存,然后读入xml根据输入参数来取得输出参数的值
以后如果有增加pIn01值的情况下,只需要增加xml的内容,无需改动代码。

请问:
1.xml该如何设计?(我只知道xml能保存固定信息,不知道如何在xml中保存if关系)
2.vbs如何读取xml?

谢谢各位了!
...全文
评论 11
收藏 已收藏
分享
返回顶部
shanyuhuang
VB基础类 7,788 成员 197,583 内容