public static void Save(VProject vProject, XmlTextWriter xml)
        {
            Debug.Assert(vProject.ProjectDescriptor != null);
            Debug.Assert(vProject.ProjectDescriptor.Code != null);
            Debug.Assert(vProject.Items != null);

            xml.WriteStartElement("Code");
            xml.WriteValue(vProject.ProjectDescriptor.Code);
            xml.WriteEndElement();

            xml.WriteStartElement("ProjectItems");
            foreach (var item in vProject.Items)
            {
                xml.WriteStartElement("ProjectItem");

                xml.WriteStartElement("DisplayName");
                xml.WriteValue(item.DisplayName);
                xml.WriteEndElement();

                xml.WriteStartElement("Code");
                xml.WriteValue(item.Descriptor.Code);
                xml.WriteEndElement();

                xml.WriteEndElement();
            }
            xml.WriteEndElement();
        }
        private string GetExpectedMods(IntegrationResult result)
        {
            System.IO.StringWriter   sw   = new System.IO.StringWriter();
            System.Xml.XmlTextWriter cbiw = new System.Xml.XmlTextWriter(sw);
            cbiw.Formatting = System.Xml.Formatting.Indented;

            cbiw.WriteStartElement("Build");
            cbiw.WriteStartAttribute("BuildDate");
            cbiw.WriteValue(DateUtil.FormatDate(result.EndTime));

            cbiw.WriteStartAttribute("Success");
            cbiw.WriteValue(result.Succeeded.ToString());

            cbiw.WriteStartAttribute("Label");
            cbiw.WriteValue(result.Label);

            if (result.Modifications.Length > 0)
            {
                cbiw.WriteStartElement("modifications");

                for (int i = 0; i < result.Modifications.Length; i++)
                {
                    result.Modifications[i].ToXml(cbiw);
                }

                cbiw.WriteEndElement();
            }

            cbiw.WriteEndElement();

            return(sw.ToString());
        }
Exemple #3
0
        void Button1Click(object sender, EventArgs e)
        {
            string str_app = Application.StartupPath;
            XmlWriter XML = new XmlTextWriter(str_app + "\\WZextract_settings.xml", Encoding.Default);
                XML.WriteStartDocument();
                    XML.WriteStartElement("Settings");
                        XML.WriteStartElement("WZ_Files");
                            if (txtWZPath.Text != "") { XML.WriteString(txtWZPath.Text); } else { XML.WriteString("None"); }
                        XML.WriteEndElement();
                        XML.WriteStartElement("PNGs");
                            if (txtPNGPath.Text != "") { XML.WriteString(txtPNGPath.Text); } else { XML.WriteString("None"); }
                        XML.WriteEndElement();
                        XML.WriteStartElement("Map_Renders");
                            if (txtMapPath.Text != "") { XML.WriteString(txtMapPath.Text); } else { XML.WriteString("None"); }
                        XML.WriteEndElement();
                        XML.WriteStartElement("MP3s");
                            if (txtMP3Path.Text != "") { XML.WriteString(txtMP3Path.Text); } else { XML.WriteString("None"); }
                        XML.WriteEndElement();
                        XML.WriteStartElement("Resolve_UOLs");
                            XML.WriteValue(chkResolveUOL.Checked);
                        XML.WriteEndElement();
                        XML.WriteStartElement("Language");
                            XML.WriteValue(cmbLanguage.SelectedIndex);
                        XML.WriteEndElement();

                    XML.WriteEndElement();
                XML.WriteEndDocument();
            XML.Close();

            this.Close();
        }
Exemple #4
0
        private void SaveSetting()
        {
            //throw new System.NotImplementedException();

            #region zhucebiao
            //RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("SoftWare", true);
            //RegistryKey SQKey = softwareKey.CreateSubKey("SQPress");
            //RegistryKey selfWindowsKey = SQKey.CreateSubKey("selfWindowsKey");
            //selfWindowsKey.SetValue("BackColor", (object)BackColor.ToKnownColor());
            //selfWindowsKey.SetValue("Red", (object)(int)BackColor.R);
            //selfWindowsKey.SetValue("Green", (object)(int)BackColor.G);
            //selfWindowsKey.SetValue("Blue", (object)(int)BackColor.B);
            //selfWindowsKey.SetValue("Width", (object)Width);
            //selfWindowsKey.SetValue("Height", (object)Height);
            //selfWindowsKey.SetValue("X", (object)DesktopLocation.X);
            //selfWindowsKey.SetValue("Y", (object)DesktopLocation.Y);
            //selfWindowsKey.SetValue("WindowState", (object)WindowState.ToString());

            //softwareKey.Close();
            //SQKey.Close();
            //selfWindowsKey.Close();
            #endregion

            #region ISO
            IsolatedStorageFile iso         = IsolatedStorageFile.GetUserStoreForDomain();
            var isoStream                   = new IsolatedStorageFileStream("SelfPlace.xml", FileMode.Create, FileAccess.ReadWrite);
            System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(isoStream, Encoding.Default);
            writer.Formatting = System.Xml.Formatting.Indented;


            writer.WriteStartDocument();
            writer.WriteStartElement("Settings");

            writer.WriteStartElement("Width");
            writer.WriteValue(this.Width);
            writer.WriteEndElement();

            writer.WriteStartElement("Height");
            writer.WriteValue(this.Height);
            writer.WriteEndElement();

            writer.WriteStartElement("X");
            writer.WriteValue(this.DesktopLocation.X);
            writer.WriteEndElement();

            writer.WriteStartElement("Y");
            writer.WriteValue(this.DesktopLocation.Y);
            writer.WriteEndElement();

            writer.WriteEndElement();

            writer.Flush();
            writer.Close();

            isoStream.Close();
            iso.Close();
            #endregion
        }
 public override void toXml(XmlTextWriter writer)
 {
     writer.WriteStartElement(Constants.BASICSEARCH_PREFIX, "basicsearch", Constants.BASICSEARCH_NAMESPACE);
     writer.WriteValue(Constants.BASICSEARCH_PREFIX + Constants.SELECT);
     writer.WriteValue(Constants.BASICSEARCH_PREFIX + Constants.PROP);
     writer.WriteValue(Constants.BASICSEARCH_PREFIX + Constants.FROM);
     writer.WriteValue(Constants.BASICSEARCH_PREFIX + Constants.WHERE);
     writer.WriteEndElement();
 }
Exemple #6
0
        protected override void OnClosed(EventArgs e)
        {
            // write settings to file
            System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(settingsPath, null)
            {
                Indentation = 1,
                IndentChar = '\t',
                Formatting = System.Xml.Formatting.Indented
            };

            writer.WriteStartElement("Settings");

            writer.WriteStartElement("Keys");

            writer.WriteStartElement("Up");
            writer.WriteValue(GameInputKeys.Up.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("Down");
            writer.WriteValue(GameInputKeys.Down.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("Left");
            writer.WriteValue(GameInputKeys.Left.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("Right");
            writer.WriteValue(GameInputKeys.Right.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("Jump");
            writer.WriteValue(GameInputKeys.Jump.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("Shoot");
            writer.WriteValue(GameInputKeys.Shoot.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("Start");
            writer.WriteValue(GameInputKeys.Start.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("Select");
            writer.WriteValue(GameInputKeys.Select.ToString());
            writer.WriteEndElement();

            writer.WriteEndElement();

            writer.WriteEndElement();
            writer.Close();
            base.OnClosed(e);
        }
Exemple #7
0
        public void Save()
        {
            var projectPath = Path.Combine(ProjectDir, Name + FileExtension);
            using (var xml = new XmlTextWriter(projectPath, Encoding.UTF8))
            {
                Debug.Assert(Id != Guid.Empty);
                Debug.Assert(Name != null);
                Debug.Assert(Code != null);
                Debug.Assert(Items != null);

                xml.Formatting = Formatting.Indented;

                xml.WriteStartDocument();
                xml.WriteStartElement("Project");

                xml.WriteStartElement("Id");
                xml.WriteValue(Id.ToString());
                xml.WriteEndElement();

                xml.WriteStartElement("Name");
                xml.WriteValue(Name);
                xml.WriteEndElement();

                xml.WriteStartElement("Code");
                xml.WriteValue(Code);
                xml.WriteEndElement();

                xml.WriteStartElement("Items");
                foreach (var item in Items)
                {
                    xml.WriteStartElement("Item");

                    xml.WriteStartElement("Name");
                    xml.WriteValue(item.Name);
                    xml.WriteEndElement();

                    xml.WriteStartElement("Type");
                    xml.WriteValue(item.Type);
                    xml.WriteEndElement();

                    xml.WriteEndElement();
                }
                xml.WriteEndElement();

                xml.WriteEndElement(); // Project
                xml.WriteEndDocument();
            }
        }
Exemple #8
0
        public static void Write(VCase vCase)
        {
            var path = Path.Combine(vCase.CaseDir, vCase.Name + FileExtension);
            using (var xml = new XmlTextWriter(path, Encoding.UTF8))
            {
                xml.Formatting = Formatting.Indented;
                xml.WriteStartDocument();
                xml.WriteStartElement("Case");

                xml.WriteStartElement("Name");
                xml.WriteValue(vCase.Name);
                xml.WriteEndElement();

                xml.WriteStartElement("CaseItems");
                foreach (var item in vCase.Items)
                {
                    xml.WriteStartElement("CaseItem");

                    xml.WriteStartElement("Id");
                    xml.WriteValue(item.Id.ToString());
                    xml.WriteEndElement();

                    xml.WriteStartElement("DisplayName");
                    xml.WriteValue(item.DisplayName);
                    xml.WriteEndElement();

                    xml.WriteStartElement("RelativePath");
                    xml.WriteValue(item.RelativePath ?? "");
                    xml.WriteEndElement();

                    var vProject = item as VProject;
                    if (vProject != null)
                    {
                        xml.WriteStartElement("Type");
                        xml.WriteValue(ProjectItem);
                        xml.WriteEndElement();

                        ProjectHandler.Save(vProject, xml);
                    }

                    xml.WriteEndElement();
                }
                xml.WriteEndElement();

                xml.WriteEndElement(); // Case
                xml.WriteEndDocument();
            }
        }
Exemple #9
0
        /// <summary>
        /// Deletes a Category
        /// </summary>
        /// <param name="category">Which category? - The Category reference</param>
        public override void DeleteCategory(Category category)
        {
            List<Category> categories = Category.Categories;
              categories.Remove(category);
              string fileName = _Folder + "Categories.xml";

              if (File.Exists(fileName))
            File.Delete(fileName);

              if (Category.Categories.Contains(category))
            Category.Categories.Remove(category);

              using (XmlTextWriter writer = new XmlTextWriter(fileName, System.Text.Encoding.UTF8))
              {
            writer.Formatting = Formatting.Indented;
            writer.Indentation = 4;
            writer.WriteStartDocument(true);
            writer.WriteStartElement("categories");

            foreach (Category cat in categories)
            {
              writer.WriteStartElement("category");
              writer.WriteAttributeString("id", cat.Id.ToString());
              writer.WriteAttributeString("description", cat.Description);
              writer.WriteValue(cat.Title);
              writer.WriteEndElement();
              cat.MarkOld();
            }

            writer.WriteEndElement();
              }
        }
        public void SaveConfiguration(string p)
        {
            XmlTextWriter writer = new XmlTextWriter(p, Encoding.ASCII);
            writer.WriteStartElement("Configuration");

            writer.WriteStartElement("DataFolder");
            writer.WriteValue(DataFolder);
            writer.WriteEndElement();

            writer.WriteStartElement("UrlList");
            writer.WriteValue(UrlList);
            writer.WriteEndElement();

            writer.WriteEndElement();
            writer.Close();
        }
Exemple #11
0
        static void WriteMyAssetSet(FileInfo[] files)
        {
            string shortfile;

            XmlTextWriter xmlwriter = new XmlTextWriter("MyAssetSet.xml", null);

            xmlwriter.Formatting = System.Xml.Formatting.Indented;
            xmlwriter.IndentChar = ' ';
            xmlwriter.Indentation = 2;

            xmlwriter.WriteStartElement("Nini");

            foreach (FileInfo f in files)
            {
                shortfile = Path.GetFileNameWithoutExtension(f.FullName);

                xmlwriter.WriteStartElement("Section");
                xmlwriter.WriteStartAttribute("Name");
                xmlwriter.WriteValue(shortfile);
                xmlwriter.WriteEndAttribute();

                WriteKey(xmlwriter, "assetID", shortfile);
                WriteKey(xmlwriter, "name", shortfile);
                WriteKey(xmlwriter, "assetType", "0");
                WriteKey(xmlwriter, "inventoryType", "0");
                WriteKey(xmlwriter, "fileName", f.Name);

                xmlwriter.WriteEndElement();
            }

            xmlwriter.WriteEndElement();
            xmlwriter.Close();
        }
Exemple #12
0
        /// <summary>
        /// 创建SiteMap文件
        /// </summary>
        /// <param name="path">路径</param>
        /// <param name="fileName">文件名</param>
        /// <param name="urlList">地址列表</param>
        public static void CreateSiteMap(string path, string fileName, IList<OurUrl> urlList)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            XmlTextWriter xmlWriter = new XmlTextWriter(path + @"/" + fileName, Encoding.UTF8);
            xmlWriter.WriteStartDocument();
            xmlWriter.WriteWhitespace("\n");
            xmlWriter.WriteStartElement("urlset");
            foreach (OurUrl url in urlList)
            {
                xmlWriter.WriteWhitespace("\n  ");
                xmlWriter.WriteStartElement("url");
                xmlWriter.WriteWhitespace("\n    ");

                xmlWriter.WriteStartElement("loc");
                xmlWriter.WriteValue(url.Loc);
                xmlWriter.WriteEndElement();
                xmlWriter.WriteWhitespace("\n    ");

                xmlWriter.WriteStartElement("lastmod");
                xmlWriter.WriteValue(GetLastModString(url.LastMod));
                xmlWriter.WriteEndElement();
                xmlWriter.WriteWhitespace("\n    ");

                xmlWriter.WriteStartElement("changefreq");
                xmlWriter.WriteValue(url.ChangeFreq.ToString().ToLower());
                xmlWriter.WriteEndElement();
                xmlWriter.WriteWhitespace("\n    ");

                xmlWriter.WriteStartElement("priority");
                xmlWriter.WriteValue(url.Priority);
                xmlWriter.WriteEndElement();
                xmlWriter.WriteWhitespace("\n  ");

                xmlWriter.WriteEndElement();
            }
            xmlWriter.WriteWhitespace("\n");
            xmlWriter.WriteEndElement();
            xmlWriter.WriteWhitespace("\n");
            xmlWriter.WriteEndDocument();
            xmlWriter.Flush();
            xmlWriter.Close();
        }
        public override void Action(MouseState mouse)
        {
            // The file:
            string filename = "\\\\psf\\Home\\Documents\\Lenguajes\\C#\\ColorWars\\ColorWars\\ColorWarsContent\\olor.xml";

            // Create a new file and open it
            XmlTextWriter textWriter = new XmlTextWriter(filename, null);
            textWriter.Formatting = Formatting.Indented;
            textWriter.WriteStartDocument();

            // Write game
            textWriter.WriteStartElement("graph");

            // Write arcs
            textWriter.WriteStartElement("arcs");

            for (int i = 0; i != GameMode.polygons.Count; ++i)
            {
                for (int j = i + 1; j < GameMode.polygons.Count; ++j)
                {
                    textWriter.WriteStartElement("arc");

                    textWriter.WriteStartElement("i");
                    textWriter.WriteValue(i);
                    textWriter.WriteEndElement();

                    textWriter.WriteStartElement("j");
                    textWriter.WriteValue(j);
                    textWriter.WriteEndElement();

                    textWriter.WriteStartElement("cost");
                    textWriter.WriteValue(GameMode.movement.arcs[i, j]);
                    textWriter.WriteEndElement();

                    textWriter.WriteEndElement();
                }
            }
            textWriter.WriteEndElement();

            textWriter.WriteEndElement();

            // Ends the document and close writer
            textWriter.WriteEndDocument();
            textWriter.Close();
        }
 public void SaveToFile(string text1)
 {
     XmlTextWriter writer = null;
     writer = new XmlTextWriter(text1, Encoding.Default);
     writer.Formatting = Formatting.Indented;
     writer.WriteStartDocument();
     writer.WriteStartElement("root");
     writer.WriteStartElement("BetSuccessSwitching");
     writer.WriteStartAttribute("IsBetSuccessSwitchingEnable");
     writer.WriteValue(Conversion.Val(this._isBetSuccessSwitchingEnable).ToString());
     writer.WriteEndAttribute();
     writer.WriteStartAttribute("BetSuccessSwitchingValue");
     writer.WriteValue(this._objBetSuccessSwitchingOpotion.get_SwitchingValue().ToString());
     writer.WriteEndAttribute();
     writer.WriteEndElement();
     writer.Flush();
     writer.Close();
 }
Exemple #15
0
        protected static void ConvertPostToXML(Post post, XmlTextWriter writer)
        {
            writer.WriteStartElement("post");
            writer.WriteAttributeString("id", post.Id.ToString());
            writer.WriteElementString("title", post.Title);
            writer.WriteElementString("body", post.Body);
            writer.WriteElementString("postBody", post.PostBody);
            writer.WriteElementString("extendedBody", post.ExtendedBody);
            writer.WriteElementString("categoryId", post.CategoryId.ToString());
            writer.WriteElementString("commentCount", post.CommentCount.ToString());
            writer.WriteElementString("pendingCommentCount", post.PendingCommentCount.ToString());
            writer.WriteElementString("author", post.UserName);
            writer.WriteElementString("publishedDate", post.Published.ToString());
            writer.WriteElementString("status", post.Status.ToString());
            writer.WriteElementString("viewCount", post.Views.ToString());
            writer.WriteElementString("url", new Macros().FullUrl(post.Url));
            writer.WriteElementString("name", post.Name);
            writer.WriteElementString("isDeleted", post.IsDeleted.ToString());
            writer.WriteElementString("tags", post.TagList);
            writer.WriteElementString("views", post.Views.ToString());
            writer.WriteElementString("image", post.ImageUrl);
            writer.WriteElementString("notes", post.Notes);
            writer.WriteElementString("contenttype", post.ContentType);
            writer.WriteElementString("revision", post.Version.ToString());
            writer.WriteElementString("sortOrder", post.SortOrder.ToString());

            writer.WriteElementString("modifiedBy", post.ModifiedBy);
            writer.WriteElementString("createdBy", post.CreatedBy);
            writer.WriteElementString("modifiedOn", post.ModifiedOn.ToString());
            writer.WriteElementString("createdOn", post.CreatedOn.ToString());

            writer.WriteElementString("enableComments", post.EnableComments.ToString());
            writer.WriteElementString("isPublished", post.IsPublished.ToString());
            writer.WriteElementString("isHome", post.IsHome.ToString());
            writer.WriteElementString("homeSortOrder", post.HomeSortOrder.ToString());
            writer.WriteElementString("parentId", post.ParentId.ToString());

            writer.WriteElementString("metaDescription", post.MetaDescription);
            writer.WriteElementString("metaKeywords", post.MetaKeywords);

            writer.WriteElementString("isFeatured", (SiteSettings.Get().FeaturedId == post.Id).ToString());
            writer.WriteElementString("isFeaturedCategory", (post.Category.FeaturedId == post.Id).ToString());

            writer.WriteStartElement("customFields");
            foreach(string key in post.CustomFields().AllKeys)
            {
                writer.WriteStartElement("customField");
                writer.WriteAttributeString("key", key);
                writer.WriteValue(post.Custom(key));

                writer.WriteEndElement();
            }

            writer.WriteEndElement();

            writer.WriteEndElement();
        }
Exemple #16
0
        private void button1_Click(object sender, EventArgs e)
        {
            //SAVE FILE
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.Filter = "*.xml|*.xml";

            //LOAD FILE
            if (dialog.ShowDialog() == DialogResult.OK)
            using( FileStream fs = new FileStream(dialog.FileName, FileMode.Create, FileAccess.Write))
            using (XmlTextWriter writer = new XmlTextWriter(fs, Encoding.Unicode))
            {

                writer.Indentation = 1;
                writer.IndentChar = '\t';
                writer.Formatting = Formatting.Indented;

                writer.WriteStartDocument();

                writer.WriteStartElement("Equipment");

                MySqlCommand command = new MySqlCommand("SELECT `Equipement` FROM `equipment` WHERE `CharId`=?CharId", conn);
                command.Parameters.AddWithValue("CharId", uint.Parse(textBox1.Text, NumberFormatInfo.InvariantInfo));

                MySqlDataReader reader = command.ExecuteReader(CommandBehavior.SequentialAccess);
                while (reader.Read())
                {
                    byte[] buffer = new byte[67];
                    int offset = 0;
                    for (int i = 0; i < 15; i++)
                    {
                        //READ IT CHUNKED
                        reader.GetBytes(0, offset, buffer, 0, 67);
                        writer.WriteStartElement("Item");

                        //WRITES THE ITEM ID
                        writer.WriteStartElement("ItemId");
                        writer.WriteValue(BitConverter.ToUInt32(buffer, 0));
                        writer.WriteEndElement();

                        //WRITES THE DURABILITY OF THE ITEM
                        writer.WriteStartElement("Durability");
                        writer.WriteValue(BitConverter.ToUInt16(buffer, 51));
                        writer.WriteEndElement();

                        writer.WriteEndElement();
                        offset += 67;
                    }
                }

                reader.Close();

                writer.WriteEndElement();
                writer.WriteEndDocument();
            }
        }
Exemple #17
0
        protected override void OnClosed(EventArgs e)
        {
            // write settings to file
            System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(settingsPath, null)
            {
                Indentation = 1,
                IndentChar  = '\t',
                Formatting  = System.Xml.Formatting.Indented
            };

            writer.WriteStartElement("Settings");

            writer.WriteStartElement("Keys");

            writer.WriteStartElement("Up");
            writer.WriteValue(GameInputKeys.Up.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("Down");
            writer.WriteValue(GameInputKeys.Down.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("Left");
            writer.WriteValue(GameInputKeys.Left.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("Right");
            writer.WriteValue(GameInputKeys.Right.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("Jump");
            writer.WriteValue(GameInputKeys.Jump.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("Shoot");
            writer.WriteValue(GameInputKeys.Shoot.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("Start");
            writer.WriteValue(GameInputKeys.Start.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("Select");
            writer.WriteValue(GameInputKeys.Select.ToString());
            writer.WriteEndElement();

            writer.WriteEndElement();

            writer.WriteEndElement();
            writer.Close();
            base.OnClosed(e);
        }
        public static void SaveParameters()
        {
            try
            {
                XmlTextWriter writer = new XmlTextWriter("params.xml", System.Text.Encoding.UTF8);

                writer.Formatting = Formatting.Indented;
                writer.WriteStartDocument();

                writer.WriteStartElement("RegionEditor");

                if (MulPath != "")
                {
                    writer.WriteStartElement("mulpath");

                    writer.WriteStartAttribute("path");
                    writer.WriteValue(_MulPath);
                    writer.WriteEndAttribute();

                    writer.WriteEndElement();
                }

                if (RegionsFile != "")
                {
                    writer.WriteStartElement("script");

                    writer.WriteStartAttribute("file");
                    writer.WriteValue(_RegionsFile);
                    writer.WriteEndAttribute();

                    writer.WriteEndElement();
                }

                if (Compatibility)
                {
                    writer.WriteStartElement("client");

                    writer.WriteStartAttribute("compatibilitymode");
                    writer.WriteValue(Compatibility);
                    writer.WriteEndAttribute();

                    writer.WriteEndElement();
                }

                writer.WriteEndElement();

                writer.WriteEndDocument();

                writer.Close();
            }
            catch { }
        }
        static void Main(string[] args)
        {
            MemoryStream ms = new MemoryStream();

            XmlTextWriter xtw =
                new XmlTextWriter(ms, Encoding.UTF8);
            xtw.Formatting = Formatting.Indented;
            //xtw.WriteProcessingInstruction(
            //    "xml", "version=\"1.0\" standalone=\"yes\"");

            xtw.WriteStartDocument();

            xtw.WriteStartElement("NorthwindDataSet");

            xtw.WriteStartElement("Products");
            xtw.WriteAttributeString("CategoryID", "1");

            xtw.WriteStartElement("ProductID");

            xtw.WriteValue(1);

            xtw.WriteEndElement();

            xtw.WriteStartElement("ProductName");

            xtw.WriteValue("Chai");

            xtw.WriteEndElement();

            xtw.WriteEndElement();

            xtw.WriteEndElement();

            xtw.WriteEndDocument();

            xtw.Flush();

            Console.WriteLine(Encoding.UTF8.GetString(ms.ToArray()));
        }
        private static void escribirXML()
        {
            XmlTextWriter escritorXML = new XmlTextWriter("agenda.xml", null);
            escritorXML.Formatting = Formatting.Indented;
            escritorXML.WriteStartDocument(true);
            escritorXML.WriteStartElement("DocumentElement");

            StreamReader lector = File.OpenText("agenda.txt");
            string linea;
            do
            {
                linea = lector.ReadLine();
                if(linea != null)
                {
                    string [] valores = linea.Split(';');
                    escritorXML.WriteStartElement("contactos");
                    escritorXML.WriteStartElement("nombre");
                    escritorXML.WriteValue(valores[0]);
                    escritorXML.WriteEndElement();
                    escritorXML.WriteStartElement("apellido");
                    escritorXML.WriteValue(valores[1]);
                    escritorXML.WriteEndElement();
                    escritorXML.WriteStartElement("email");
                    escritorXML.WriteValue(valores[2]);
                    escritorXML.WriteEndElement();
                    escritorXML.WriteStartElement("telefono");
                    escritorXML.WriteValue(valores[3]);
                    escritorXML.WriteEndElement();
                    escritorXML.WriteEndElement();
                }
            }
            while(linea != null);
            escritorXML.WriteEndElement();
            escritorXML.WriteEndDocument();
            escritorXML.Close();

            lector.Close();
        }
Exemple #21
0
        /// <summary>
        /// 将返回的数据转换为XML并输出到响应流。
        /// </summary>
        /// <param name="value"></param>
        /// <param name="total"></param>
        public static void ReturnPicsList(IList<share> value, int total)
        {
            XmlTextWriter xw = new XmlTextWriter(HttpContext.Current.Response.Output);
            xw.Formatting = Formatting.Indented;
            xw.Indentation = 2;
            xw.WriteStartDocument();
            xw.WriteStartElement("return");

            xw.WriteStartElement("code");
            xw.WriteValue("0");
            xw.WriteEndElement();
            xw.WriteStartElement("total");
            xw.WriteValue(total);
            xw.WriteEndElement();
            xw.WriteStartElement("list");
            foreach (share item in value)
            {
                xw.WriteStartElement("item");

                xw.WriteElementString(share.Columns.id, item.Id.ToString());
                xw.WriteElementString(share.Columns.sina_uid, item.Sina_uid);
                xw.WriteElementString(share.Columns.sina_name, item.Sina_name);
                xw.WriteStartElement(share.Columns.comment);
                xw.WriteCData(item.Comment);
                xw.WriteEndElement();
                xw.WriteElementString(share.Columns.img, item.Img);
                xw.WriteElementString(share.Columns.type, item.Type);

                xw.WriteEndElement();
            }
            xw.WriteEndElement();
            xw.WriteEndElement();
            xw.Close();

            HttpContext.Current.Response.ContentType = "text/xml";
            HttpContext.Current.Response.End();
        }
Exemple #22
0
		public string Htmlize (IXPathNavigable doc)
		{
			var navigator = doc.CreateNavigator ();
			var errorName = navigator.SelectSingleNode ("//ErrorDocumentation/ErrorName");
			var details = navigator.SelectSingleNode ("//ErrorDocumentation/Details");

			StringWriter sw = new StringWriter ();
			XmlWriter w = new XmlTextWriter (sw);
			
			WriteElementWithClass (w, "div", "header");
			w.WriteAttributeString ("id", "error_ref");
			WriteElementWithClass (w, "div", "subtitle", "Compiler Error Reference");
			WriteElementWithClass (w, "div", "title", "Error " + (errorName == null ? string.Empty : errorName.Value));
			w.WriteEndElement ();

			if (details != null) {
				WriteElementWithClass (w, "div", "summary", "Summary");

				var summary = details.SelectSingleNode ("/Summary");
				w.WriteValue (summary == null ? string.Empty : summary.Value);
				
				WriteElementWithClass (w, "div", "details", "Details");
				var de = details.SelectSingleNode ("/Details");
				w.WriteValue (de == null ? string.Empty : de.Value);
			}
			
			foreach (XPathNavigator xmp in navigator.Select ("//ErrorDocumentation/Examples/string")) {
				WriteElementWithClass (w, "div", "code_example");
				WriteElementWithClass (w, "div", "code_ex_title", "Example");
				w.WriteRaw (Mono.Utilities.Colorizer.Colorize (xmp.Value, "c#"));;
				w.WriteEndElement ();
			}
			
			w.Close ();
			
			return sw.ToString ();
		}
Exemple #23
0
        /// <summary>
        /// Сохранение истории задачи в отдельный XML-файл
        /// </summary>
        /// <param name="taskname">Название задачи</param>
        /// <param name="his">История задачи</param>
        /// <param name="fname">Полный путь и имя файла для сохранения</param>
        public static void SaveTaskHistoryToXMLFile(string taskname, THistory[] his, string fname)
        {
            XmlTextWriter file = new XmlTextWriter(fname, Encoding.UTF8);

            file.WriteStartDocument();
            file.WriteComment("Definition of task history data");
            file.WriteStartElement("history");
            file.WriteStartAttribute("taskname");
            file.WriteValue(taskname);
            for (int i = 0; i < his.Length; i++)
            {
                file.WriteStartElement("helement");
                file.WriteStartAttribute("date");
                file.WriteValue(his[i].Date);
                file.WriteStartAttribute("type");
                file.WriteValue(his[i].Type.ToString());
                file.WriteStartAttribute("value");
                file.WriteValue(his[i].Value);
                file.WriteEndElement();
            }
            file.WriteEndElement();

            file.Close();
        }
        public string Serialize()
        {
            StringBuilder result = new StringBuilder(100);

            using (TextWriter textWriter = new StringWriter(result, CultureInfo.InvariantCulture))
            using (XmlWriter xmlWriter = new XmlTextWriter(textWriter))
            {
                xmlWriter.WriteStartDocument();
                xmlWriter.WriteStartElement("CustomXmlSerializable");

                xmlWriter.WriteStartElement("Id");
                xmlWriter.WriteValue(this.Id.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Value1");
                xmlWriter.WriteValue(this.Value1);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Value2");
                xmlWriter.WriteValue(this.Value2);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Value3");
                xmlWriter.WriteValue(this.Value3);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Value4");
                xmlWriter.WriteValue(this.Value4);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndDocument();
            }

            return result.ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // Prevent caching in the browser
            Response.Clear();
            Response.CacheControl = "no-cache";
            Response.Cache.SetNoStore();
            Response.AddHeader("Pragma", "no-cache");
            Response.Expires = -1;

            // Set the content type of our response to XML
            Response.ContentType = "text/xml";

            try
            {
                // ensure the id argument is not null
                if (Request["id"] == null && Request["type"] == null)
                {
                    throw new Exception("Not a valid \"id\" argument");
                }

                string id = Request["id"];
                string type = Request["type"];
                Root root = CreateDataFile(id, type);

                XmlSerializer serializer =
                    new XmlSerializer(typeof(Root));

                serializer.Serialize(
                    this.Response.OutputStream, root);

                this.Response.OutputStream.Close();
            }
            catch (Exception error)
            {
                // if any error occurs, return an error message
                XmlTextWriter writer =
                    new XmlTextWriter(
                         this.Response.OutputStream,
                         Encoding.UTF8);
                writer.WriteStartElement("error");
                writer.WriteValue(error.Message);
                writer.WriteEndElement();
                writer.Close();
                return;
            }
        }
Exemple #26
0
        private static void Save()
        {
            XmlWriter xml = new XmlTextWriter("wrapper.xml",Encoding.UTF8);
            xml.WriteStartDocument();

            xml.WriteStartElement("config");
            foreach (KeyValuePair<string, string> kvp in Stuff)
            {
                xml.WriteStartElement("entry");
                xml.WriteAttributeString("name", kvp.Key);
                xml.WriteValue(kvp.Value);
                xml.WriteEndElement();
            }
            xml.WriteEndElement();

            xml.WriteEndDocument();
            xml.Close();
        }
Exemple #27
0
        /// <summary>
        /// Запись кэша меток в отдельный XML файл
        /// </summary>
        /// <param name="buf">Кэш меток</param>
        /// <param name="fname">Полный путь и название файла для сохранения</param>
        public static void SaveLabelsCacheToXMLFile(LabelsCache buf, string fname)
        {
            XmlTextWriter file = new XmlTextWriter(fname, Encoding.UTF8);

            file.WriteStartDocument();
            file.WriteComment("Definition of labels cache data");
            file.WriteStartElement("labels");
            for (int i = 0; i < buf.GetLabelsCount; i++)
            {
                file.WriteStartElement("label");
                file.WriteStartAttribute("value");
                file.WriteValue(buf[i]);
                file.WriteEndElement();
            }
            file.WriteEndElement();

            file.Close();
        }
        private static void Traverse(string dir, XmlTextWriter writer)
        {
            foreach (var directory in Directory.GetDirectories(dir))
            {
                writer.WriteStartElement("dir");
                writer.WriteAttributeString("path", directory);
                Traverse(directory, writer);
                writer.WriteEndElement();
            }

            foreach (var file in Directory.GetFiles(dir))
            {
                writer.WriteStartElement("file");
                writer.WriteAttributeString("ext", Path.GetExtension(file));
                writer.WriteValue(Path.GetFileNameWithoutExtension(file));
                writer.WriteEndElement();
            }
        }
Exemple #29
0
            /// <summary>
            /// Writes the XML element.
            /// </summary>
            /// <param name="writer">The writer.</param>
            virtual protected void WriteXMLElement(System.Xml.XmlTextWriter writer)
            {
                writer.WriteAttributeString("type", this.ResourceType.Name);
                writer.WriteAttributeString("name", _name);
                writer.WriteAttributeString("id", ID.ToString());
                writer.WriteElementString("family", (Parent != null) ? Parent.QualifiedName : "");

                foreach (FieldValueList fieldValues in this.Fields.Values)
                {
                    foreach (object v in fieldValues.Values)
                    {
                        writer.WriteStartElement("field");
                        writer.WriteAttributeString("name", fieldValues.Type.Name);
                        writer.WriteValue(v.ToString());
                        writer.WriteEndElement();
                    }
                }
            }
Exemple #30
0
        public static string GetFriendsXML(int MemberID)
        {
            StringWriter stringWriter = new StringWriter();

            XmlTextWriter writer = new XmlTextWriter(stringWriter);

            try
            {
                writer.WriteStartDocument();

                writer.WriteStartElement("FriendsList");

                Friend[] Friends = Friend.GetAllFriendsByMemberIDWithJoin(MemberID);

                for (int i = 0; i < Friends.Length; i++)
                {
                    writer.WriteStartElement("Friend");
                    writer.WriteValue(Friends[i].Member.NickName);
                    writer.WriteEndElement();
                }

                //List<Member> Friends = Member.GetAllMember();

                //for (int i = 0; i < Friends.Count; i++)
                //{
                //    writer.WriteStartElement("Friend");
                //    writer.WriteValue(Friends[i].NickName);
                //    writer.WriteEndElement();
                //}

                writer.WriteEndElement();

                writer.WriteEndDocument();


            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: {0}", e.ToString());
            }

            return stringWriter.ToString();
        }
        private void RenderSiteTemplates(HttpContext context, XmlTextWriter xmlTextWriter)
        {
            List<ContentTemplate> templates = ContentTemplate.GetAll(siteSettings.SiteGuid);

            foreach (ContentTemplate template in templates)
            {
                if (!WebUser.IsInRoles(template.AllowedRoles)) { continue; }

                xmlTextWriter.WriteStartElement("Template");
                xmlTextWriter.WriteAttributeString("title", template.Title);
                xmlTextWriter.WriteAttributeString("image", template.ImageFileName);
                xmlTextWriter.WriteStartElement("Description");
                xmlTextWriter.WriteValue(template.Description);
                xmlTextWriter.WriteEndElement();

                xmlTextWriter.WriteStartElement("Html");
                xmlTextWriter.WriteCData(template.Body);
                xmlTextWriter.WriteEndElement(); //Html
                xmlTextWriter.WriteEndElement(); //Template

            }
        }
Exemple #32
0
        static void WriteMySiteLibraryFolders(string folderID)
        {
            XmlTextWriter xmlwriter = new XmlTextWriter("MySiteLibraryFolders.xml", null);

            xmlwriter.Formatting = System.Xml.Formatting.Indented;
            xmlwriter.IndentChar = ' ';
            xmlwriter.Indentation = 2;

            xmlwriter.WriteStartElement("Nini");
            xmlwriter.WriteStartElement("Section");
            xmlwriter.WriteStartAttribute("Name");
            xmlwriter.WriteValue("MySiteLibraryFolder");
            xmlwriter.WriteEndAttribute();

            WriteKey(xmlwriter, "folderID", folderID);
            WriteKey(xmlwriter, "parentFolderID", "00000112-000f-0000-0000-000100bba000");
            WriteKey(xmlwriter, "name", "MySiteLibraryFolder");
            WriteKey(xmlwriter, "type", "0");

            xmlwriter.WriteEndElement();
            xmlwriter.WriteEndElement();
            xmlwriter.Close();
        }
        private static void GenerateSample(int sampleNumber, string outputDirectory)
        {
            var filePath = Path.Combine(
                outputDirectory, string.Concat("sensors", sampleNumber.ToString(CultureInfo.InvariantCulture), ".xml"));

            using (var fileStream = new FileStream(filePath, FileMode.CreateNew))
            {
                using (var writer = new XmlTextWriter(fileStream, Encoding.ASCII))
                {
                    writer.WriteStartDocument();
                    writer.WriteStartElement("sensors");

                    writer.WriteStartElement("sensor");
                    writer.WriteAttributeString("name", "temperature");
                    writer.WriteValue((Random.NextDouble() - 0.2d) * 50d);
                    writer.WriteEndElement();

                    writer.WriteEndElement();
                    writer.WriteEndDocument();

                    writer.Flush();
                }
            }
        }
        private void WriteWorkflowEvents(IList<TrackingWorkflowEvent> events, XmlTextWriter writer)
        {
            if ((null == events) || (0 == events.Count))
                return;

            writer.WriteStartElement("TrackingWorkflowEvents");

            foreach (TrackingWorkflowEvent s in events)
            {
                if (!IsWorkflowEvent((int)s))
                    throw new ArgumentException(ExecutionStringManager.InvalidWorkflowEvent);

                writer.WriteStartElement("TrackingWorkflowEvent");
                writer.WriteValue(s.ToString());
                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }