我正在使用XML解析器和Oracle一起從數據庫中獲取數據。當我在gridview中顯示它時,它只顯示最後一個值而不是3個值。我使用:c中的xmlparser#
doc.LoadXml(str);
XPathNavigator nav = doc.CreateNavigator();
XPathNodeIterator iterator = nav.Select("//new[@*]");
drNewRow = dt.NewRow();
while (iterator.MoveNext())
{
drNewRow = dt.NewRow();
dt.Columns.Add("service");
dt.Columns.Add("entity");
dt.Columns.Add("updated");
XPathNavigator nav2 = iterator.Current.Clone();
XPathNavigator nav3 = iterator.Current.Clone();
nav2.MoveToFirstAttribute();
nav3.MoveToParent();
// lt.Items.Add(nav3.Name + "" + nav2.Name + "" + nav2.va);
drNewRow["service"] = nav3.Name;
drNewRow["entity"] = nav2.Name;
drNewRow["updated"] = nav2.Value;
dt.Rows.Add(drNewRow);
dt.AcceptChanges();
}
gw.DataSource = dt;
gw.DataBind();
看到我的答案更新。 – siride