【发布时间】:2011-08-03 18:55:52
【问题描述】:
我有以下 xml 文件:
<courses>
<course>
<name>Course 1</name>
<code>00162</code>
<questions>2,2,1,1,2,1,1,1</questions>
</course>
</courses>
我需要查询文件(我正在使用 xpath)来拆分 'questions' 元素,检查每个数字出现的位置并检查它是数字 1 还是 2。
基本上我需要在 xpath 中这样做:
Dim ints As String() = QuestionsString.ToString.Split(",")
Dim i As Integer
For i = 0 To UBound(ints)
If ints(i) = "2" Then
'do something
Else
'do something else
End If
Next
来自 cmets 的更新
您好,谢谢。我打算编辑 问题,因为它是不正确的。我想要 例如,获取所有课程名称 和“问题”元素的代码 (拆分后)第二个有“2” 位置,如 1,2,2,1,1,1,2,1 谢谢!
【问题讨论】: