XML为数据集 - 问题,找到了什么数据行包含数据表 [英] XML to dataset - problem finding what datarow contains a datatable

查看:107
本文介绍了XML为数据集 - 问题,找到了什么数据行包含数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,如果描述很差,但我不知道该怎么把这个... 但这里是XML结构的例​​子

Sorry if the description is poor, but I don't know how else to put this... But here is an example of the XML structure

<?xml version="1.0" encoding="UTF-8">
<Response xmlns="http://www.blah.com">
  <searchResult>
    <info>
      <firstName>John</firstName>
      <lastName>Doe</lastName>
      <totalCharges>100.00</totalCharges>
      <nonPaymentCode>99999</nonPaymentCode>
    </info>
    <info>
      <firstName>Susan</firstName>
      <lastName>Doe</lastName>
      <totalCharges>1000.00</totalCharges>
      <errorCodes>
        <errorCode>12345</errorCode>
      </errorCodes>
    </info>
    <info>
      <firstName>Peter</firstName>
      <lastName>Doe</lastName>
      <totalCharges>10.00</totalCharges>
      <errorCodes>
        <errorCode>12345</errorCode>
        <errorCode>54321</errorCode>
        <errorCode>85246</errorCode>
      </errorCodes>
    </info>
  </searchResult>
</claimInquiryResponse>

我已经以获取信息为数据表转化为数据集这一点。 但我的问题是试图让C $ CS错误$。我试图弄清楚这一点通过检查表的关系。因为我必须要弄清楚什么错误codeS是什么人有关,为了正确地显示它们。我无法控制XML结构,一切都是可选的,以减少过多的带宽,因此更改它不是在这一点上的一个选项。但这里是我所做的例子:

I have transformed this into a dataset in order to access the information as a datatable. But my problem is trying to get the errorCodes. I was trying to figure this out by checking the relationship of the tables. Because I have to figure out what error codes are associated with what person, in order to display them properly. I cannot control the XML structure, and everything is optional in order to reduce excess bandwidth so changing it is not an option at this point. But here is an example of what I have done:

For Each rel As DataRelation In ds.Tables(i).ChildRelations
    If rel.Nested Then
        Dim temp As New DataTable
        temp = rel.ChildTable
        For Each relationship As DataRelation In temp.ChildRelations
            For Each row As DataRow In relationship.ChildTable.Rows
                For Each column As DataColumn In relationship.ChildTable.Columns
                    rowValues &= column.ColumnName & "-" & row(column.ColumnName) & "-" & relationship.RelationName & vbCrLf
                Next
            Next
        Next
    End If
Next

这使我有数据的实际值C $ CS表错误$内。但我无法弄清楚如何链接回给它关联了什么行/人。的关系产生被内置了他们的次数的指标(例如错误$ C $客服本苏珊将是0和彼得这将是1),不涉及在XML自己的位置。

This gives me the actual values of the data inside of errorCodes table. but I can't figure out how to link it back to what row/person it was associated with. The indexes the relationship generate are built off of their occurance (for instance the error codes for susan will be 0 and for peter it will be 1), not relating to their location in the XML.

我要么这样做不对,或看着这个数据不正确。 我知道我可以使用XML阅读器来获得这一切,但数据已经在数据集,我觉得学习新的东西。所以只能建议其作为最后的手段吧。

I am either doing this wrong or looking at this data incorrectly. I know I can use a XML reader to get all this, but the data is already in the dataset, and I feel like learning something new. so only suggest it as a last resort please.

在此先感谢!

推荐答案

最后我只是读通过XML检查节点名称,建设一个独立的表中的错误codeS,当我发现结束元素信息我吐出来的表分别。

I ended up just reading through the XML checking the node name and building a separate table for the error codes, and when I found the end element for info I spat out the tables individually.

这篇关于XML为数据集 - 问题,找到了什么数据行包含数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆