当前位置: 首页>>代码示例>>C#>>正文


C# DataSet.GetXml方法代码示例

本文整理汇总了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();
        }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:19,代码来源:Test036.cs

示例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
 }
开发者ID:RabbitProgram,项目名称:WebAppBanana,代码行数:21,代码来源:StringHelps.cs

示例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);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:44,代码来源:DataSetTest2.cs

示例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());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:21,代码来源:DataSetTest2.cs

示例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);
            }
开发者ID:x55756016,项目名称:TMReminder,代码行数:26,代码来源:SQLiteHelper.cs

示例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());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:15,代码来源:DataSetTest2.cs


注:本文中的DataSet.GetXml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。