使用C#开发的Web Service,使用VB调用, 现在调用已经成功了,但是返回的是XML,我该怎么把这个XML字符转换成VB中的Recordset?或者说在VB中我们一般对于 XML怎么进行处理呢?
解决方案 »
- 颜色x与y重叠得出颜色Z,怎样计算Z地
- 如何使列表框中的项上下移动排序?
- 这个问题我发了三次贴了,可是没有能给我解答???why?
- Form大小为300*200,Picture中的图片大小为1024*768,如何在FORM中平滑的移动Picture中的图片(无闪烁)。
- 关于函数。
- 我在网吧上网机器上没VB, 不知那位大哥大姐知道那有vb6下载?
- 请问什么地方有好的英文VB网站和新闻组?
- 用VB6能不能查到Cpu或硬盘的ID号?
- 提问问题能给的最高分与自己的哪个分数有关系,怎么我有近1000的分可用分,每次只能给别人几十分
- 一个关于数据报表的问题~请帮忙
- 急!!!如何往binary 里添加内容?在线等待,马上给分
- 如何让安装程序注册第三方控件?
Public Function ConvertXMLtoRecordset(ByVal voNL As IXMLDOMNodeList, ByVal vsTableName As String) As ADODB.Recordset
Dim oTableNode As IXMLDOMNode
Dim oRecordNode As IXMLDOMNode
Dim oFieldNode As IXMLDOMNode
Dim oNodeList As IXMLDOMNodeList
Dim oRS As ADODB.Recordset
Dim sXPath As String
Dim lLength As Long ' Create Recordset using the xsd schema
sXPath = "//xs:element[@name=""" & vsTableName & """]/xs:complexType/xs:sequence"
Set oTableNode = voNL.Item(1).selectSingleNode(sXPath) Set oRS = New ADODB.Recordset ' Iterate trough all fields
For Each oFieldNode In oTableNode.childNodes
If Not oFieldNode.Attributes Is Nothing Then
' Retrieve Max Length
lLength = 0
If oFieldNode.Attributes(1).Text = "xs:string" Then
' Find all records of current field
sXPath = "//" & vsTableName & "/" & oFieldNode.Attributes(0).Text
Set oNodeList = voNL.Item(1).selectNodes(sXPath) ' Iterate trough all records
For Each oRecordNode In oNodeList
If Len(oRecordNode.Text) > lLength Then
lLength = Len(oRecordNode.Text)
End If
Next
End If ' Add Field
On Error Resume Next
Call oRS.Fields.Append(oFieldNode.Attributes(0).Text, GetDataType(oFieldNode.Attributes(1).Text), lLength)
End If
Next ' Add the data to the empty Recordset
sXPath = "//" & vsTableName
Set oNodeList = voNL.Item(1).selectNodes(sXPath) Call oRS.Open ' Iterate trough all records
For Each oRecordNode In oNodeList
' Add Record
Call oRS.AddNew ' Iterate trough all fields of current record
For Each oFieldNode In oRecordNode.childNodes
If Len(oFieldNode.baseName) > 0 Then
' Set value
oRS.Fields(oFieldNode.baseName) = oFieldNode.Text
End If
Next
Next ' Return the Recordset
If Not (oRS.BOF And oRS.EOF) Then Call oRS.MoveFirst
Set ConvertXMLtoRecordset = oRS
End FunctionPrivate Function GetDataType(ByVal vsType As String) As ADODB.DataTypeEnum
' Convert the XSD datatype to a ADO datatype
Select Case vsType
Case "xs:string"
GetDataType = adVarChar
Case "xs:int"
GetDataType = adInteger
Case "xs:dateTime"
GetDataType = adDate
Case "xs:decimal"
GetDataType = adDouble
Case "xs:short"
GetDataType = adBoolean
Case "0"
GetDataType = adVarChar
End Select
End Function