コード例 #1
0
ファイル: Program.cs プロジェクト: alasdairhurst/nginn
        static void DataTest()
        {
            DataObject dob = new DataObject();
            dob["ala"] = "ma kota";
            dob["jola"] = "nie ma zielonego pojêcia";
            dob["zenek"] = 35;
            dob["dziœ"] = DateTime.Now;
            dob["ala"] = "ju¿ nie ma kota";
            dob["kot"] = new List<string>(new string[] { "skarpeta", "tiger", "filemon", "kuba" });
            StringBuilder sb = new StringBuilder();

            foreach (string k in dob.Keys)
            {
                log.Debug("{0}={1}", k, dob[k]);
            }
            DataObject dob2 = new DataObject((IDataObject) dob);

            XmlWriter xw = XmlWriter.Create(sb);
            dob2.ToXml("dob2", xw);
            xw.Flush();
            log.Debug("XML: {0}", sb.ToString());
            string xml = "<?xml version=\"1.0\" ?><data id=\"11\">   <member1>aaa</member1> <member1>bbb</member1>  <and>\n<otherData>tutaj</otherData>\n<more>...</more></and>\n<member3>\nsome\ntext</member3>\n</data>";
            log.Debug("Parsing XML: {0}", xml);
            StringReader sr = new StringReader(xml);
            XmlReader xr = XmlReader.Create(sr);
            xr.MoveToContent();
            DataObject dob3 = DataObject.ParseXmlElement(xr);
            log.Debug("Result: {0}", dob3.ToXmlString("dob3"));
        }