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