如何在 VB.NET 中将 Web 服务输出(XMLNode)转换为数据集
本文关键字:XMLNode 转换 数据集 输出 服务 VB NET Web 中将 | 更新日期: 2023-09-27 18:36:51
我编写了如下代码
Dim xNode As XmlNode xNode = proclaimService.ProClaim_Get_Exclusions(sSQL) XmlData = New StringReader(xNode.OuterXml) Dim xmlString As String xmlString = xNode.OuterXml
在 xmlString 中,我在下面得到
<NewDataSet xmlns="">
<Table>
<company />
<Policy>10163067</Policy>
<Rec_ty>Ex</Rec_ty>
<Seq_no xml:space="preserve"></Seq_no>
<Dt_last_updt>Dec 3 2003</Dt_last_updt>
<Coverage_no>All</Coverage_no>
<Client_no>65083406</Client_no>
<Document_name>Exclusion</Document_name>
<Print_ind />
<Retention_ind />
<Exclusion_type>Exclu</Exclusion_type>
<Comment01>blessure,maladie ou trouble d'un ou des deux genoux, y compr</Comment01>
<comment02>is les complications, traitements ou chirurgies connexes.</comment02>
<comment03 xml:space="preserve"></comment03>
<comment04 xml:space="preserve"></comment04>
<comment05 xml:space="preserve"></comment05>
<comment06 xml:space="preserve"></comment06>
<comment07 xml:space="preserve"></comment07>
<comment08 xml:space="preserve"></comment08>
<comment09 xml:space="preserve"></comment09>
<comment10 xml:space="preserve"></comment10>
</Table>
</NewDataSet>
我正在使用以下代码来创建数据集
XmlData = New StringReader(xmlString) reader = New XmlTextReader(XmlData) xmlDs.ReadXml(reader) Dset = xmlDs
但是在 XmlData 中我什么也得不到.....如何使用 VB.NET???将其转换为数据集
没有更多的信息,很难知道如何回答。 下面是一个处理文件的示例。 请注意注释。
Dim xmlStrm As New IO.StreamReader(pathToFile)
'xmlStrm could be a .GetResponseStream from a web response
'Dim xmlStrm As IO.Stream = someWebResp.GetResponseStream
Dim Dset As New DataSet
Using reader As Xml.XmlReader = Xml.XmlReader.Create(xmlStrm)
Dset.ReadXml(reader)
End Using
xmlStrm.Close()
xmlStrm.Dispose()
Debug.WriteLine(Dset.Tables.Count)
For Each rw As DataRow In Dset.Tables(0).Rows
'as example show first two columns
Debug.WriteLine(rw(0).ToString & " " & rw(1).ToString)
Next
编辑:从返回 XML 的网站
Dim someReq As Net.WebRequest = Net.WebRequest.Create(someURL)
Dim someResp As Net.WebResponse = someReq.GetResponse()
Dim someStrm As IO.Stream = someResp.GetResponseStream()
Dim someDoc As New Xml.XmlDocument
someDoc.Load(someStrm)
Dim xe As XElement = XElement.Parse(someDoc.InnerXml)
Dim Dset As New DataSet
Using reader As Xml.XmlReader = xe.CreateReader
Dset.ReadXml(reader)
End Using
Debug.WriteLine(Dset.Tables.Count)