我有像
这样的数据集<DATASET>
<SALES_DO_INDEPENDENT>
<SALES_DO_INDEPENDENT_ID>22</SALES_DO_INDEPENDENT_ID>
<DO_CODE>1234</DO_CODE>
<SALES_DO_STATUS_ID>1</SALES_DO_STATUS_ID>
<COM_CUSTOMER_ID>1</COM_CUSTOMER_ID>
<COM_PRODUCT_ID>9</COM_PRODUCT_ID>
<COM_TRANSPORT_COMPANY_ID>8</COM_TRANSPORT_COMPANY_ID>
<SHIPPING_DATE>28/07/2011 0:00:00</SHIPPING_DATE>
<SHIPPING_ADDRESS>SS</SHIPPING_ADDRESS>
<DO_DESCR>SS</DO_DESCR>
<TRANSPORT_LICENSE_CODE>123</TRANSPORT_LICENSE_CODE>
<COM_USER_ID>1</COM_USER_ID>
<IS_SYNCHRONIZED>False</IS_SYNCHRONIZED>
<IS_SAMPLE>False</IS_SAMPLE>
<COM_WAREHOUSE_ID>3</COM_WAREHOUSE_ID>
</SALES_DO_INDEPENDENT>
<SALES_DO_INDEPENDENT>
<SALES_DO_INDEPENDENT_ID>11</SALES_DO_INDEPENDENT_ID>
<DO_CODE>1234</DO_CODE>
<SALES_DO_STATUS_ID>1</SALES_DO_STATUS_ID>
<COM_CUSTOMER_ID>1</COM_CUSTOMER_ID>
<COM_PRODUCT_ID>9</COM_PRODUCT_ID>
<COM_TRANSPORT_COMPANY_ID>8</COM_TRANSPORT_COMPANY_ID>
<SHIPPING_DATE>28/07/2011 0:00:00</SHIPPING_DATE>
<SHIPPING_ADDRESS>SS</SHIPPING_ADDRESS>
<DO_DESCR>SS</DO_DESCR>
<TRANSPORT_LICENSE_CODE>123</TRANSPORT_LICENSE_CODE>
<COM_USER_ID>1</COM_USER_ID>
<IS_SYNCHRONIZED>False</IS_SYNCHRONIZED>
<IS_SAMPLE>False</IS_SAMPLE>
<COM_WAREHOUSE_ID>3</COM_WAREHOUSE_ID>
</SALES_DO_INDEPENDENT>
</DATASET>
如何使用SALES_DO_INDEPENDENT_ID = 11获取数据集中的数据行 我的意思是结果
<DATASET>
<SALES_DO_INDEPENDENT>
<SALES_DO_INDEPENDENT_ID>11</SALES_DO_INDEPENDENT_ID>
<DO_CODE>1234</DO_CODE>
<SALES_DO_STATUS_ID>1</SALES_DO_STATUS_ID>
<COM_CUSTOMER_ID>1</COM_CUSTOMER_ID>
<COM_PRODUCT_ID>9</COM_PRODUCT_ID>
<COM_TRANSPORT_COMPANY_ID>8</COM_TRANSPORT_COMPANY_ID>
<SHIPPING_DATE>28/07/2011 0:00:00</SHIPPING_DATE>
<SHIPPING_ADDRESS>SS</SHIPPING_ADDRESS>
<DO_DESCR>SS</DO_DESCR>
<TRANSPORT_LICENSE_CODE>123</TRANSPORT_LICENSE_CODE>
<COM_USER_ID>1</COM_USER_ID>
<IS_SYNCHRONIZED>False</IS_SYNCHRONIZED>
<IS_SAMPLE>False</IS_SAMPLE>
<COM_WAREHOUSE_ID>3</COM_WAREHOUSE_ID>
</SALES_DO_INDEPENDENT>
</DATASET>
先谢谢
此致 Yusan Susandi。
答案 0 :(得分:1)
您也可以使用XPath。一种方法是通过XPathNavigator
:
XPathNavigator xpath = xmlDoc.CreateNavigator();
XPathNodeIterator xiter = xpath.Select("/DATASET/SALES_DO_INDEPENDENT[SALES_DO_INDEPENDENT_ID=11]");
while (xiter.MoveNext())
{
// do something with the values
}
另一种方法是使用XmlNode.SelectSingleNode()
:
root.SelectSingleNode("/DATASET/SALES_DO_INDEPENDENT[SALES_DO_INDEPENDENT_ID=11]");
答案 1 :(得分:0)
试试这个:
Dim selectedRows As DataRow() = yourDataSet.Tables(0).Select("SALES_DO_INDEPENDENT_ID = 11")
注意Select
方法针对DataTable而不是DataSet进行操作。这个例子假定每个旧的ADO.NET都有一个普通的DataSet / DataTable。
答案 2 :(得分:0)
您可以从数据表中创建dataview并过滤:
Dim dv As New DataView(dt)
dv.RowFilter = "SALES_DO_INDEPENDENT_ID = 11"
For r As Integer = 0 To dv.Count - 1
Debug.WriteLine(dv(r).Item("DO_CODE").ToString) 'etc
Next