本文整理汇总了C#中DataSet.GetXml方法的典型用法代码示例。如果您正苦于以下问题:C# DataSet.GetXml方法的具体用法?C# DataSet.GetXml怎么用?C# DataSet.GetXml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSet
的用法示例。
在下文中一共展示了DataSet.GetXml方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Foo
private string Foo(int longIndexName, DataSet ds)
{
string Key = ds.Tables[0].Rows[0]["Key"].ToString();
if (!string.IsNullOrEmpty(Key) && Key != "SAMP")
{
try
{
ds.Tables[0].Rows[0]["Key"] = Encoding.ASCII.GetString(PerfFormOp(Convert.FromBase64String(Key), longIndexName));
ds.AcceptChanges();
}
catch (Exception ex)
{
Logging.Post(ex);
}
}
return ds.GetXml();
}
示例2: ISO8859_GB2312
//��������ת��
//��ʵ���ǽ�dataset�����ݶ�����xml�ļ���Ȼ�������
public static DataSet ISO8859_GB2312(DataSet ds)
{
#region
string xml;
xml = ds.GetXml();
ds.Clear();
//�����ַ���
System.Text.Encoding iso8859, gb2312;
//iso8859
iso8859 = System.Text.Encoding.GetEncoding("iso8859-1");
//����2312
gb2312 = System.Text.Encoding.GetEncoding("gb2312");
byte[] bt;
bt = iso8859.GetBytes(xml);
xml = gb2312.GetString(bt);
ds.ReadXml(new System.IO.StringReader(xml));
return ds;
#endregion
}
示例3: GetXml
public void GetXml()
{
var ds = new DataSet();
ds.Namespace = "namespace"; //if we don't add namespace the test will fail because GH (by design) always add namespace
DataTable dt = DataProvider.CreateParentDataTable();
dt.Clear();
dt.Rows.Add(new object[] { 1, "Value1", "Value2" });
dt.Rows.Add(new object[] { 2, "Value3", "Value4" });
dt.Rows.Add(new object[] { 3, "Value5", "Value5" });
StringBuilder resultXML = new StringBuilder();
resultXML.Append("<" + ds.DataSetName + "xmlns=\"namespace\">");
resultXML.Append("<Parent>");
resultXML.Append("<ParentId>1</ParentId>");
resultXML.Append("<String1>Value1</String1>");
resultXML.Append("<String2>Value2</String2>");
resultXML.Append("</Parent>");
resultXML.Append("<Parent>");
resultXML.Append("<ParentId>2</ParentId>");
resultXML.Append("<String1>Value3</String1>");
resultXML.Append("<String2>Value4</String2>");
resultXML.Append("</Parent>");
resultXML.Append("<Parent>");
resultXML.Append("<ParentId>3</ParentId>");
resultXML.Append("<String1>Value5</String1>");
resultXML.Append("<String2>Value5</String2>");
resultXML.Append("</Parent>");
resultXML.Append("</" + ds.DataSetName + ">");
ds.Tables.Add(dt);
string strXML = ds.GetXml();
strXML = strXML.Replace(" ", "");
strXML = strXML.Replace("\t", "");
strXML = strXML.Replace("\n", "");
strXML = strXML.Replace("\r", "");
// GetXml
Assert.Equal(resultXML.ToString(), strXML);
}
示例4: Copy
public void Copy()
{
DataSet ds = new DataSet(), dsTarget = null;
ds.Tables.Add(DataProvider.CreateParentDataTable());
ds.Tables.Add(DataProvider.CreateChildDataTable());
ds.Relations.Add(new DataRelation("myRelation", ds.Tables[0].Columns[0], ds.Tables[1].Columns[0]));
ds.Tables[0].Rows.Add(new object[] { 9, "", "" });
ds.Tables[1].Columns[2].ReadOnly = true;
ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns[0], ds.Tables[0].Columns[1] };
//copy data and schema
// Copy 1
dsTarget = ds.Copy();
//Assert.Equal(ds.GetXmlSchema(), dsTarget.GetXmlSchema() );
//using my function because GetXmlSchema in not implemented in java
Assert.Equal(DataProvider.GetDSSchema(ds), DataProvider.GetDSSchema(dsTarget));
// Copy 2
Assert.Equal(true, dsTarget.GetXml() == ds.GetXml());
}
示例5: ExecuteXmlReader
/// <summary>
/// Execute XmlReader with complete Command
/// </summary>
/// <param name="command">SQLite Command</param>
/// <returns>XmlReader</returns>
public static XmlReader ExecuteXmlReader(IDbCommand command)
{
// open the connection if necessary, but make sure we
// know to close it when we�re done.
if (command.Connection.State != ConnectionState.Open)
{
command.Connection.Open();
}
// get a data adapter
SQLiteDataAdapter da = new SQLiteDataAdapter((SQLiteCommand)command);
DataSet ds = new DataSet();
// fill the data set, and return the schema information
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
da.Fill(ds);
// convert our dataset to XML
StringReader stream = new StringReader(ds.GetXml());
command.Connection.Close();
// convert our stream of text to an XmlReader
return new XmlTextReader(stream);
}
示例6: RejectChanges
public void RejectChanges()
{
DataSet ds1, ds2 = new DataSet();
ds2.Tables.Add(DataProvider.CreateParentDataTable());
ds1 = ds2.Copy();
//create changes
ds2.Tables[0].Rows[0][0] = "70";
ds2.Tables[0].Rows[1].Delete();
ds2.Tables[0].Rows.Add(new object[] { 9, "string1", "string2" });
// RejectChanges
ds2.RejectChanges();
Assert.Equal(ds2.GetXml(), ds1.GetXml());
}