public static void XmlDataDocument_CloneNode()
        {
            DataSet         ds  = Create();
            DataRow         dr  = ds.Tables[0].Rows[0];
            XmlDataDocument doc = new XmlDataDocument(ds);

            ds.EnforceConstraints = false;

            XmlNode node = doc.CloneNode(deep: true);

            Assert.True(node.HasChildNodes);

            node = doc.CloneNode(deep: false);
            Assert.False(node.HasChildNodes);
        }
    public static void Main()
    {
        DataSet dsNorthwind = new DataSet();

        //Create the connection string.
        String sConnect;

        sConnect = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind";

        //Create a connection object to connect to the northwind db.
        SqlConnection nwconnect = new SqlConnection(sConnect);

        //Create a command string to select all the customers in the WA region.
        String sCommand = "Select * from Customers where Region='WA'";

        //Create an adapter to load the DataSet.
        SqlDataAdapter myDataAdapter = new SqlDataAdapter(sCommand, nwconnect);

        //Fill the DataSet with the selected records.
        myDataAdapter.Fill(dsNorthwind, "Customers");

        //Load the document with the DataSet.
        XmlDataDocument doc = new XmlDataDocument(dsNorthwind);

        //Create a shallow clone of the XmlDataDocument. Note that although
        //none of the child nodes were copied over, the cloned node does
        //have the schema information.
        XmlDataDocument clone = (XmlDataDocument)doc.CloneNode(false);

        Console.WriteLine("Child count: {0}", clone.ChildNodes.Count);
        Console.WriteLine(clone.DataSet.GetXmlSchema());
    }
Esempio n. 3
0
        public static void InitLogger()
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            startTime   = DateTime.Now;
            times       = new List <DateTime>();
            fpss        = new List <int>(1000);
            stopwatches = new List <Stopwatch>();

            doc = new XmlDataDocument();
            doc.CreateXmlDeclaration("1.0", "UTF-8", "yes");

            dbgDoc = new XmlDataDocument();
            dbgDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes");

            XmlElement   html = doc.CreateElement("html");
            XmlElement   head = doc.CreateElement("head");
            XmlElement   link = doc.CreateElement("link");
            XmlAttribute type = doc.CreateAttribute("type");

            type.InnerText = "text/css";
            link.Attributes.Append(type);
            XmlAttribute rel = doc.CreateAttribute("rel");

            rel.InnerText = "Stylesheet";
            link.Attributes.Append(rel);
            XmlAttribute href = doc.CreateAttribute("href");

            href.InnerText = "logging.css";
            link.Attributes.Append(href);

            head.AppendChild(link);
            html.AppendChild(head);

            XmlElement body = doc.CreateElement("body");
            XmlElement text = doc.CreateElement("div");

            text.InnerXml = "Logger verze 0.3; cas zacatku: " + startTime.ToString();
            body.AppendChild(text);

            html.AppendChild(body);
            doc.AppendChild(html);

            dbgDoc = (XmlDataDocument)doc.CloneNode(true);

            bodyNode    = doc.GetElementsByTagName("body")[0];
            dbgBodyNode = dbgDoc.GetElementsByTagName("body")[0];


            //Save();
            bInitialized = true;
            Console.WriteLine("Logger spusten");
            AddError("test");
        }
Esempio n. 4
0
        public void CloneNode()
        {
            XmlDataDocument doc = new XmlDataDocument();

            doc.DataSet.ReadXmlSchema("Test/System.Xml/region.xsd");
            doc.Load("Test/System.Xml/region.xml");

            XmlDataDocument doc2 = (XmlDataDocument)doc.CloneNode(false);

            Assert.AreEqual(0, doc2.ChildNodes.Count, "#I01");
            Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-16\"?>", doc2.DataSet.GetXmlSchema().Substring(0, 39), "#I02");

            doc2 = (XmlDataDocument)doc.CloneNode(true);

            Assert.AreEqual(2, doc2.ChildNodes.Count, "#I03");
            Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-16\"?>", doc2.DataSet.GetXmlSchema().Substring(0, 39), "#I04");

            doc.DataSet.Tables [0].Rows [0][0] = "64";

            Assert.AreEqual("1", doc2.DataSet.Tables [0].Rows [0][0].ToString(), "#I05");
        }