为什么DataSet.ReadXML合并元素? [英] Why is DataSet.ReadXML merging elements?

查看:91
本文介绍了为什么DataSet.ReadXML合并元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我执行下面的代码,则表明它正在将所有订单"元素合并到一个订单表中,但未维护buy_orders_order和sell_orders_order之间的分割...我如何才能仅访问购买订单或只是卖单?

我尝试过单独定义架构,但是我遇到了同样的问题.我需要某种方式来访问只显示在sell_orders元素和buy_orders元素下的order元素

PS:很抱歉,如果代码中有typeo,我要在此文本框中从mem中键入.

If I execute the code below, it shows me that it is merging all the "order" elements into a single order table, but is not maintaining the split between buy_orders_order and sell_orders_order... how can I access just the buy orders or just the sell orders???

I''ve tried defining the schema separately, but I have the same issue. I need some way to access just the order elements that show up under the sell_orders element and buy_orders element

PS: Apologies if there is a typeo in the code, I''m typing it from mem in this textbox.

using System.Data;  
   
 public void RunSample()  
 {  
     DataSet dsOrders= new DataSet();  

     // Create the web request  
     string xml_adress = "http://api.eve-central.com/api/quicklook?typeid=34®ionlimit=10000002&sethours=1";
     HttpWebRequest request= WebRequest.Create(xml_adress ) as HttpWebRequest;  
   
     // Get response  
     using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)  
     {  
         // Load data into a dataset  
         dsOrders.ReadXml(response.GetResponseStream());  
   
     }

     // Print out all tables and their columns  
     foreach (DataTable table in dsOrders.Tables)  
     {  
         Console.WriteLine("TABLE ''{0}''", table.TableName);  
         Console.WriteLine("Total # of rows: {0}", table.Rows.Count);  
         Console.WriteLine("---------------------------------------------------------------");  
         Console.WriteLine(System.Environment.NewLine);  
     }  // foreach table  
 
       
 }

推荐答案

已创建的数据集在不同表之间具有关系,以便获取供Sell_orders和buy_orders使用的行;
The dataset that has been created has relationships between the different tables so to get the rows for sell_orders and buy_orders use;
DataTable sellOrders = dsOrders.Tables["sell_orders"].Rows[0].GetChildRows("sell_orders_order").CopyToDataTable();
DataTable buyOrders = dsOrders.Tables["buy_orders"].Rows[0].GetChildRows("buy_orders_order").CopyToDataTable();


这篇关于为什么DataSet.ReadXML合并元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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