當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlDataDocument.GetElementFromRow方法代碼示例

本文整理匯總了C#中System.Xml.XmlDataDocument.GetElementFromRow方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlDataDocument.GetElementFromRow方法的具體用法?C# XmlDataDocument.GetElementFromRow怎麽用?C# XmlDataDocument.GetElementFromRow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.XmlDataDocument的用法示例。


在下文中一共展示了XmlDataDocument.GetElementFromRow方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetElementFromRow

        public void GetElementFromRow()
        {
            XmlDataDocument doc = new XmlDataDocument();
            doc.DataSet.ReadXmlSchema(new StringReader(RegionXsd));
            doc.Load(new StringReader(RegionXml));
            DataTable table = doc.DataSet.Tables["Region"];

            XmlElement element = doc.GetElementFromRow(table.Rows[2]);
            Assert.Equal("Region", element.Name);
            Assert.Equal("3", element["RegionID"].InnerText);

            try
            {
                element = doc.GetElementFromRow(table.Rows[4]);
                Assert.False(true);
            }
            catch (IndexOutOfRangeException e)
            {
                Assert.Equal(typeof(IndexOutOfRangeException), e.GetType());
                Assert.Equal("There is no row at position 4.", e.Message);
            }
        }
開發者ID:ericeil,項目名稱:corefx,代碼行數:22,代碼來源:XmlDataDocumentTest.cs

示例2: GetElementFromRow

		public void GetElementFromRow ()
		{
			XmlDataDocument doc = new XmlDataDocument ();
			doc.DataSet.ReadXmlSchema ("Test/System.Xml/region.xsd");
			doc.Load ("Test/System.Xml/region.xml");
			DataTable table = doc.DataSet.Tables ["Region"];

			XmlElement element = doc.GetElementFromRow (table.Rows [2]);
			Assert.AreEqual ("Region", element.Name, "#D01");
			Assert.AreEqual ("3", element ["RegionID"].InnerText, "#D02");

			try {
				element = doc.GetElementFromRow (table.Rows [4]);
				Assert.Fail ("#D03");
			} catch (IndexOutOfRangeException e) {
				Assert.AreEqual (typeof (IndexOutOfRangeException), e.GetType (), "#D04");
				Assert.AreEqual ("There is no row at position 4.", e.Message, "#D05");
			}
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:19,代碼來源:XmlDataDocumentTest.cs

示例3: EditingXmlTree

        public void EditingXmlTree()
        {
            XmlDataDocument doc = new XmlDataDocument();
            doc.DataSet.ReadXmlSchema(new StringReader(RegionXsd));
            doc.Load(new StringReader(RegionXml));

            XmlElement Element = doc.GetElementFromRow(doc.DataSet.Tables[0].Rows[1]);
            Element.FirstChild.InnerText = "64";
            Assert.Equal("64", doc.DataSet.Tables[0].Rows[1][0]);

            DataSet Set = new DataSet();
            Set.ReadXml(new StringReader(RegionXml));
            doc = new XmlDataDocument(Set);

            Element = doc.GetElementFromRow(doc.DataSet.Tables[0].Rows[1]);
            Assert.NotNull(Element);

            try
            {
                Element.FirstChild.InnerText = "64";
                Assert.False(true);
            }
            catch (InvalidOperationException)
            {
            }

            Assert.Equal("2", doc.DataSet.Tables[0].Rows[1][0]);

            Set.EnforceConstraints = false;
            Element.FirstChild.InnerText = "64";
            Assert.Equal("64", doc.DataSet.Tables[0].Rows[1][0]);
        }
開發者ID:ericeil,項目名稱:corefx,代碼行數:32,代碼來源:XmlDataDocumentTest.cs

示例4: EditingXmlTree

		public void EditingXmlTree ()
		{	
			XmlDataDocument doc = new XmlDataDocument ();
			doc.DataSet.ReadXmlSchema ("Test/System.Xml/region.xsd");
			doc.Load ("Test/System.Xml/region.xml");

			XmlElement Element = doc.GetElementFromRow (doc.DataSet.Tables [0].Rows [1]);
			Element.FirstChild.InnerText = "64";
			Assert.AreEqual ("64", doc.DataSet.Tables [0].Rows [1] [0], "test#01");
			
			DataSet Set = new DataSet ();
			Set.ReadXml ("Test/System.Xml/region.xml");
			doc = new XmlDataDocument (Set);
			
			Element = doc.GetElementFromRow (doc.DataSet.Tables [0].Rows [1]);
			Assert.IsNotNull (Element);
			
			try {
				Element.FirstChild.InnerText = "64";
				Assert.Fail ("test#02");
			} catch (InvalidOperationException) {
			}
			
			Assert.AreEqual ("2", doc.DataSet.Tables [0].Rows [1] [0], "test#05");
			
			Set.EnforceConstraints = false;
			Element.FirstChild.InnerText = "64";
			Assert.AreEqual ("64", doc.DataSet.Tables [0].Rows [1] [0], "test#06");
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:29,代碼來源:XmlDataDocumentTest.cs


注:本文中的System.Xml.XmlDataDocument.GetElementFromRow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。