本文整理匯總了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);
}
示例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");
}