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


C# XmlDataDocument.ImportNode方法代碼示例

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


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

示例1: CreateElement1

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

            XmlElement Element = doc.CreateElement("prefix", "localname", "namespaceURI");
            Assert.Equal("prefix", Element.Prefix);
            Assert.Equal("localname", Element.LocalName);
            Assert.Equal("namespaceURI", Element.NamespaceURI);
            doc.ImportNode(Element, false);

            TextWriter text = new StringWriter();
            doc.Save(text);

            string substring = string.Empty;
            string TextString = text.ToString();

            substring = TextString.Substring(0, TextString.IndexOf("\n"));
            TextString = TextString.Substring(TextString.IndexOf("\n") + 1);

            substring = TextString.Substring(0, TextString.IndexOf("\n"));
            TextString = TextString.Substring(TextString.IndexOf("\n") + 1);
            Assert.True(substring.IndexOf("<Root>") != -1);

            substring = TextString.Substring(0, TextString.IndexOf("\n"));
            TextString = TextString.Substring(TextString.IndexOf("\n") + 1);
            Assert.True(substring.IndexOf("  <Region>") != -1);

            substring = TextString.Substring(0, TextString.IndexOf("\n"));
            TextString = TextString.Substring(TextString.IndexOf("\n") + 1);
            Assert.True(substring.IndexOf("    <RegionID>1</RegionID>") != -1);

            for (int i = 0; i < 26; i++)
            {
                substring = TextString.Substring(0, TextString.IndexOf("\n"));
                TextString = TextString.Substring(TextString.IndexOf("\n") + 1);
            }

            substring = TextString.Substring(0, TextString.Length);
            Assert.True(substring.IndexOf("</Root>") != -1);
        }
開發者ID:ericeil,項目名稱:corefx,代碼行數:42,代碼來源:XmlDataDocumentTest.cs

示例2: CreateElement1

		public void CreateElement1 ()
		{
			XmlDataDocument doc = new XmlDataDocument ();
			doc.DataSet.ReadXmlSchema ("Test/System.Xml/region.xsd");
			doc.Load ("Test/System.Xml/region.xml");
			
			XmlElement Element = doc.CreateElement ("prefix", "localname", "namespaceURI");
			Assert.AreEqual ("prefix", Element.Prefix, "test#01");
			Assert.AreEqual ("localname", Element.LocalName, "test#02");
			Assert.AreEqual ("namespaceURI", Element.NamespaceURI, "test#03");
			doc.ImportNode (Element, false);
			
			TextWriter text = new StringWriter ();
			doc.Save(text);

			string substring = string.Empty;
			string TextString = text.ToString ();

			substring = TextString.Substring (0, TextString.IndexOf("\n"));
			TextString = TextString.Substring (TextString.IndexOf("\n") + 1);

			substring = TextString.Substring (0, TextString.IndexOf("\n"));
			TextString = TextString.Substring (TextString.IndexOf("\n") + 1);
			Assert.IsTrue (substring.IndexOf ("<Root>") != -1, "test#05");

			substring = TextString.Substring (0, TextString.IndexOf("\n"));
			TextString = TextString.Substring (TextString.IndexOf("\n") + 1);
			Assert.IsTrue (substring.IndexOf ("  <Region>") != -1, "test#06");

			substring = TextString.Substring (0, TextString.IndexOf("\n"));
			TextString = TextString.Substring (TextString.IndexOf("\n") + 1);
			Assert.IsTrue (substring.IndexOf ("    <RegionID>1</RegionID>") != -1, "test#07");

			for (int i = 0; i < 26; i++) {
				substring = TextString.Substring (0, TextString.IndexOf("\n"));
				TextString = TextString.Substring (TextString.IndexOf("\n") + 1);
			}

			substring = TextString.Substring (0, TextString.Length);
			Assert.IsTrue (substring.IndexOf ("</Root>") != -1, "test#08");
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:41,代碼來源:XmlDataDocumentTest.cs


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