当前位置: 首页>>代码示例>>C#>>正文


C# DataSet.ReadXml方法代码示例

本文整理汇总了C#中System.Data.DataSet.ReadXml方法的典型用法代码示例。如果您正苦于以下问题:C# DataSet.ReadXml方法的具体用法?C# DataSet.ReadXml怎么用?C# DataSet.ReadXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.DataSet的用法示例。


在下文中一共展示了DataSet.ReadXml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();
            DataSet ds1 = new DataSet();
            ds.ReadXml(@"D:\Books.xml");

            bookgrd.DataSource = ds.Tables[0];
            bookgrd.DataBind();

            IEnumerable<DataRow> tbl1row = ds.Tables[0].AsEnumerable();
            ds1.ReadXml(@"D:\Books2.xml");

            IEnumerable<DataRow> tbl2row = ds1.Tables[0].AsEnumerable();
            GridView1.DataSource = ds1.Tables[0];
            GridView1.DataBind();

            var items = tbl2row.AsEnumerable().Select(r => r.Field<string>("id"))
            .Except(tbl1row.AsEnumerable().Select(r => r.Field<string>("id")));

            DataTable TableC = (from row in tbl2row.AsEnumerable()
                                join id in items
                                on row.Field<string>("id") equals id
                                select row).CopyToDataTable();

            GridView2.DataSource = TableC;
            GridView2.DataBind();
        }
开发者ID:MurugesanSP,项目名称:DataTable-Comparision-through-Linq,代码行数:27,代码来源:WebForm1.aspx.cs

示例2: ArrayBinding_Load

        private void ArrayBinding_Load(object sender, System.EventArgs e)
        {
            // Access database
            System.Windows.Forms.DataVisualization.Charting.Utilities.SampleMain.MainForm mainForm = (System.Windows.Forms.DataVisualization.Charting.Utilities.SampleMain.MainForm)this.ParentForm;

            // The XML document
            string fileNameString = mainForm.applicationPath + "\\data\\data.xml";
            string fileNameSchema = mainForm.applicationPath + "\\data\\data.xsd";

            // Initializes a new instance of the DataSet class
            DataSet custDS = new DataSet();

            // Reads an XML schema into the DataSet.
            custDS.ReadXmlSchema( fileNameSchema );

            // Reads XML schema and data into the DataSet.
            custDS.ReadXml( fileNameString );

            // Initializes a new instance of the DataView class
            DataView firstView = new DataView(custDS.Tables[0]);

            Chart1.Series.Clear();
            // Since the DataView implements and IEnumerable, pass the reader directly into
            // the DataBindTable method with the name of the column used for the X value.
            Chart1.DataBindTable(firstView, "Name");

            // Set series appearance
            Chart1.Series[0].ChartType = SeriesChartType.Bar;
            Chart1.Series[0].Font = new Font("Trebuchet MS", 8);
            Chart1.Series[0].Color = System.Drawing.Color.FromArgb(220, 224,64,10);
            Chart1.Series[0].BorderWidth = 0;
        }
开发者ID:zhaohengyi,项目名称:WinChartControlerSamples,代码行数:32,代码来源:XMLData.cs

示例3: XmlToCsvUsingDataSet

        public XmlToCsvUsingDataSet(string xmlSourceFilePath, bool autoRenameWhenNamingConflict)
        {
            XmlDataSet = new DataSet();
            try
            {
                XmlDataSet.ReadXml(xmlSourceFilePath);

                foreach (DataTable table in XmlDataSet.Tables)
                {
                    TableNameCollection.Add(table.TableName);
                }
            }
            catch (DuplicateNameException)
            {
                if (autoRenameWhenNamingConflict)
                {
                    XmlDataSet.ReadXml(xmlSourceFilePath, XmlReadMode.IgnoreSchema);

                    foreach (DataTable table in XmlDataSet.Tables)
                    {
                        TableNameCollection.Add(table.TableName);
                    }

                    RenameDuplicateColumn();
                }
                else
                {
                    throw;
                }
            }
        }
开发者ID:Groostav,项目名称:XmlToCsv,代码行数:31,代码来源:XmlToCsvUsingDataSet.cs

示例4: Parse

        public virtual DataSet Parse(string fileName, Stream stream)
        {
            DataSet ds = new DataSet();

            if (stream != null)
            {
                ds.ReadXml(stream);
            }
            else ds.ReadXml(fileName);

            return ds;
        }
开发者ID:0anion0,项目名称:IBN,代码行数:12,代码来源:XmlIncomingDataParser.cs

示例5: DeserializeTable

        public static DataTable DeserializeTable(string filename)
        {
            DataSet ds = new DataSet();
            ds.Locale = System.Globalization.CultureInfo.InvariantCulture;

            if (File.Exists(GetPath(filename)))
                ds.ReadXml(GetPath(filename));
            else
                ds.ReadXml(GetResource(filename));
            DataTable dt = ds.Tables[0];
            ds.Tables.Remove(dt);
            return dt;
        }
开发者ID:cihypan,项目名称:biold,代码行数:13,代码来源:Helper.cs

示例6: helloWorldTest

        public void helloWorldTest()
        {
            DataSet helloworld = new DataSet();
            helloworld.ReadXml(ConfigurationSettings.AppSettings["XmlPath"].ToString());
            sceenshotpath=helloworld.Tables[0].Rows[0].ItemArray[10].ToString();
            baseUrl = helloworld.Tables[1].Rows[0].ItemArray[1].ToString() + ":" + "//" + helloworld.Tables[1].Rows[0].ItemArray[2].ToString() + ":" + helloworld.Tables[1].Rows[0].ItemArray[3].ToString() + "/" + helloworld.Tables[1].Rows[0].ItemArray[0].ToString();
            Directory.CreateDirectory(helloworld.Tables[0].Rows[0].ItemArray[9].ToString());
           try
            {
               //Opens Phresco Home Page.   
               driver.Navigate().GoToUrl(baseUrl);
               //Click on site actions and go to edit page.
               driver.FindElement(By.XPath(helloworld.Tables[0].Rows[0].ItemArray[4].ToString())).Click();
               driver.FindElement(By.XPath(helloworld.Tables[0].Rows[0].ItemArray[5].ToString())).Click();
               Thread.Sleep(Convert.ToInt32(helloworld.Tables[0].Rows[0].ItemArray[3].ToString()));
               //Close the hello world web part.
               driver.FindElement(By.XPath(helloworld.Tables[0].Rows[0].ItemArray[6].ToString())).Click();
               Thread.Sleep(Convert.ToInt32(helloworld.Tables[0].Rows[0].ItemArray[3].ToString()));                        
               driver.Navigate().Refresh();
               driver.Navigate().GoToUrl(baseUrl);
                            
               }
            catch (Exception e)
            {

                TakeScreenshot(driver, helloworld.Tables[0].Rows[0].ItemArray[10].ToString());
                throw e;
                
            }
        }
开发者ID:photon-infotech,项目名称:sharepoint-hw,代码行数:30,代码来源:AllTest.cs

示例7: Bind

 private void Bind(string strTypeID,string strTypeName="")
 {
     DataSet ds = new DataSet();
     ds.ReadXml(Server.MapPath("~/FileManager/File.xml"));
     DataRow[] drs = null;
     if (strTypeID != "")
     {
          drs = ds.Tables[0].Select("ParentID='" + strTypeID + "'");
     }
     else
     {
         drs = ds.Tables[0].Select("ParentID='0'");
     }
     DataTable dt = ds.Tables[0].Clone();
     foreach (DataRow dr in drs)
     {
         dt.Rows.Add(dr.ItemArray);
     }
     dt.AcceptChanges();
     this.dgDocView.DataSource = dt;
     this.dgDocView.DataBind();
     ViewState["TypeID"] = strTypeID;
     ViewState["TypeName"] = strTypeName;
     lbTypeName.Text = strTypeName;
 }
开发者ID:uwitec,项目名称:tonsinoa,代码行数:25,代码来源:FileList.aspx.cs

示例8: BindDir

        private void BindDir(string strTypeID)
        {
            DataSet ds = new DataSet();
            ds.ReadXml(Server.MapPath("~/SystemManager/Document.xml"));
            DataTable dt = ds.Tables[0].Clone();
            DataRow[] drs = null;
            drs = ds.Tables[0].Select("ParentID='" + strTypeID + "'");

            drpDir.Items.Clear();
            drpDir.Items.Add(new ListItem("/", ViewState["TypeID"].ToString()));
            if (drs.Length > 0)
            {
                foreach (DataRow dr in drs)
                {
                    //dt.Rows.Add(dr.ItemArray);

                    ListItem item = new ListItem("/" + dr["TypeName"].ToString(), dr["TypeID"].ToString());
                    drpDir.Items.Add(item);
                }
            }

            drpDir.SelectedValue = "0";
            //dt.AcceptChanges();

            //drpDir.DataSource = dt;
            //drpDir.DataTextField = "TypeName";
            //drpDir.DataValueField="TypeID";
            //drpDir.DataBind();
        }
开发者ID:uwitec,项目名称:tonsinoa,代码行数:29,代码来源:FileList.aspx.cs

示例9: ConvertXMLFileToDataSet

 //将xml文件转换为DataSet
 public static DataSet ConvertXMLFileToDataSet(string xmlFile)
 {
     StringReader stream = null;
     XmlTextReader reader = null;
     try
     {
         XmlDocument xmld = new XmlDocument();
         xmld.Load(xmlFile);
         DataSet xmlDS = new DataSet();
         stream = new StringReader(xmld.InnerXml);
         //从stream装载到XmlTextReader
         reader = new XmlTextReader(stream);
         xmlDS.ReadXml(reader);
         //xmlDS.ReadXml(xmlFile);
         return xmlDS;
     }
     catch (System.Exception ex)
     {
         throw ex;
         //MessageBox.Show(ex.ToString());
     }
     //finally
     //{
     //    if (reader != null) reader.Close();
     //}
 }
开发者ID:icegithub,项目名称:csharp-exercise,代码行数:27,代码来源:XmlDatasetConvert.cs

示例10: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
		// create the connection, DataAdapter and DataSet
		string connectionString = WebConfigurationManager.ConnectionStrings["Northwind"].ConnectionString;
		string sql = "SELECT TOP 5 EmployeeID, TitleOfCourtesy, LastName, FirstName FROM Employees";
		SqlConnection conn = new SqlConnection(connectionString);
		SqlDataAdapter da = new SqlDataAdapter(sql, conn);
		DataSet ds = new DataSet();

		// Fill the DataSet and fill the first grid.
		da.Fill(ds, "Employees");
		Datagrid1.DataSource = ds.Tables["Employees"];
		Datagrid1.DataBind();

		// Generate the XML file.
		string xmlFile = Server.MapPath("Employees.xml");
		ds.WriteXml(xmlFile, XmlWriteMode.WriteSchema);

		// Load the XML file.
		DataSet dsXml = new DataSet();
		dsXml.ReadXml(xmlFile);
		// Fill the second grid.
		Datagrid2.DataSource = dsXml.Tables["Employees"];
		Datagrid2.DataBind();

    }
开发者ID:Helen1987,项目名称:edu,代码行数:26,代码来源:DataSetXml.aspx.cs

示例11: GetTemplateVarList

	    /// <summary>
		/// 获得模板变量列表
		/// </summary>
		/// <param name="forumpath">模板路径</param>
		/// <param name="skinName">皮肤名</param>
		/// <returns></returns>
		public static DataTable GetTemplateVarList(string forumpath,string skinName)
		{
			Discuz.Cache.DNTCache cache = Cache.DNTCache.GetCacheService();
            DataTable dt = cache.RetrieveSingleObject("/Forum/" + skinName + "/TemplateVariable") as DataTable;            

			if(dt == null)
			{
                DataSet dsSrc = new DataSet("template");

                string[] filename = { Utils.GetMapPath(forumpath + "templates/" + skinName + "/templatevariable.xml") };

                if (Utils.FileExists(filename[0]))
                {
                    dsSrc.ReadXml(filename[0]);
                    if (dsSrc.Tables.Count == 0)
                        dsSrc.Tables.Add(TemplateVariableTable());
                }
                else
                {
                    dsSrc.Tables.Add(TemplateVariableTable());
                }
                dt = dsSrc.Tables[0];
                cache.AddSingleObject("/Forum/" + skinName + "/TemplateVariable", dt, filename);
			}
            return dt;
		}
开发者ID:wenysky,项目名称:dnt31-lite,代码行数:32,代码来源:ForumPageTemplate.cs

示例12: GetData

 /// <summary>
 /// 读取指定节点的值
 /// </summary>
 /// <param name="XmlPathNode">节点的XPATH</param>
 /// <returns>返回一个DataView</returns>
 public DataSet GetData(string XmlPathNode)
 {
     DataSet ds = new DataSet();
     StringReader read = new StringReader(objXmlDoc.SelectSingleNode(XmlPathNode).OuterXml);
     ds.ReadXml(read);
     return ds;
 }
开发者ID:zhanglc8801,项目名称:WKT2015,代码行数:12,代码来源:XMLOper.cs

示例13: mergeToolStripMenuItem_Click

        private void mergeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();
            ds.ReadXml("data.xml");

            mailMerge1.Merge(ds.Tables[0]);
        }
开发者ID:TextControl,项目名称:TextControl.MailMerge.CRLF,代码行数:7,代码来源:Form1.cs

示例14: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            //Create a DataSet from the XML file
            string filePath = "..\\..\\Employees.xml";
            DataSet ds = new DataSet();
            ds.ReadXml(filePath);

            //Create and add barcode column
            DataColumn dc = new DataColumn("BarcodeImage", typeof(byte[]));
            ds.Tables[0].Columns.Add(dc);

            //We'll use Code 128 Barcode Symbology
            BaseBarcode b = BarcodeFactory.GetBarcode(Symbology.Code128);

            b.Height = 50;
            b.FontHeight = 0.3F;
            //Now, generate and fill barcode images
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                //We'll encode the ID column
                b.Number = (string)dr["ID"];

                //Create bitmap and save it to BarcodeImage column
                MemoryStream ms = new MemoryStream();
                b.Save(ms, ImageType.Png);
                dr["BarcodeImage"] = ms.GetBuffer();
            }

            CrystalReport1 report = new CrystalReport1();
            report.SetDataSource(ds);
            crystalReportViewer1.ReportSource = report;
        }
开发者ID:BGCX261,项目名称:zlap-svn-to-git,代码行数:32,代码来源:Form1.cs

示例15: Inventory1_Load

        private void Inventory1_Load(object sender, EventArgs e)
        {
            lblItemCode.Text = CERPInventory.ItemCode;
            lblItemDesc.Text = CERPInventory.ItemDesc;

            CERPWS.Service1 svc = new CERPWS.Service1();
            string result = svc.GetWarehouseInventory(CERPInventory.ItemID);

            StringReader sr = new StringReader(result);
            DataSet ds = new DataSet();
            DataTable dt = new DataTable("table");
            ds.ReadXml(sr);
            dt = ds.Tables[0];
            if (dt.Rows[0].ItemArray[0].ToString() == "0")
            {
                MessageBox.Show(dt.Rows[0].ItemArray[1].ToString());
                CERPInventory.Qty = 0;
                lblQty.Text = CERPInventory.Qty.ToString();
                lblUOM.Text = "";

                CERPInventory.OutOfStock = true;
            }
            else
            {
                CERPInventory.Qty = Convert.ToDecimal(dt.Rows[0].ItemArray[0].ToString());
                CERPInventory.UOM = dt.Rows[0].ItemArray[1].ToString();
                lblQty.Text = CERPInventory.Qty.ToString("G29");
                lblUOM.Text = CERPInventory.UOM;

                CERPInventory.OutOfStock = false;
            }
        }
开发者ID:jedsilvestregit,项目名称:CERP-Portable,代码行数:32,代码来源:Inventory1.cs


注:本文中的System.Data.DataSet.ReadXml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。