如何将 Web 服务输出(XMLNode)转换为 VB.NET 中的数据集?

How to convert Web service output(XMLNode) to Dataset in VB.NET?

我写的代码如下

            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)