WriteStartElement() public method

public WriteStartElement ( string prefix, string localName, string ns ) : void
prefix string
localName string
ns string
return void
        public static string Serialize(IEnumerable<MicroDataEntry> entries)
        {
            StringBuilder sb = new StringBuilder(3000);
            using (StringWriter sw = new StringWriter(sb))
            {
                using (XmlTextWriter xw = new XmlTextWriter(sw))
                {
                    xw.WriteStartElement("microData");

                    foreach (MicroDataEntry microDataEntry in entries)
                    {
                        xw.WriteStartElement("entry");

                        if (microDataEntry.ContentType.HasValue)
                        {
                            xw.WriteAttributeString("contentType", microDataEntry.ContentType.Value.ToString());
                        }

                        xw.WriteAttributeString("entryType", microDataEntry.Type.ToString());
                        xw.WriteAttributeString("selector", microDataEntry.Selector);
                        xw.WriteAttributeString("value", microDataEntry.Value);

                        xw.WriteEndElement();
                    }

                    xw.WriteEndElement();
                }
            }

            return sb.ToString();
        }
Example #2
1
        private void CreateConfig()
        {
            this.ConfigFileLocation = Path.Combine(this.ThemeDirectory, "Theme.config");

            using (var xml = new XmlTextWriter(this.ConfigFileLocation, Encoding.UTF8))
            {
                xml.WriteStartDocument(true);
                xml.Formatting = Formatting.Indented;
                xml.Indentation = 4;

                xml.WriteStartElement("configuration");
                xml.WriteStartElement("appSettings");

                this.AddKey(xml, "ThemeName", this.Info.ThemeName);
                this.AddKey(xml, "Author", this.Info.Author);
                this.AddKey(xml, "AuthorUrl", this.Info.AuthorUrl);
                this.AddKey(xml, "AuthorEmail", this.Info.AuthorEmail);
                this.AddKey(xml, "ConvertedBy", this.Info.ConvertedBy);
                this.AddKey(xml, "ReleasedOn", this.Info.ReleasedOn);
                this.AddKey(xml, "Version", this.Info.Version);
                this.AddKey(xml, "Category", this.Info.Category);
                this.AddKey(xml, "Responsive", this.Info.Responsive ? "Yes" : "No");
                this.AddKey(xml, "Framework", this.Info.Framework);
                this.AddKey(xml, "Tags", string.Join(",", this.Info.Tags));
                this.AddKey(xml, "HomepageLayout", this.Info.HomepageLayout);
                this.AddKey(xml, "DefaultLayout", this.Info.DefaultLayout);

                xml.WriteEndElement(); //appSettings
                xml.WriteEndElement(); //configuration
                xml.Close();
            }
        }
Example #3
1
        private bool SaveRegister(string RegisterKey)
        {
            try
            {
                
                Encryption enc = new Encryption();
                FileStream fs = new FileStream("reqlkd.dll", FileMode.Create);
                XmlTextWriter w = new XmlTextWriter(fs, Encoding.UTF8);

                // Khởi động tài liệu.
                w.WriteStartDocument();
                w.WriteStartElement("QLCV");

                // Ghi một product.
                w.WriteStartElement("Register");
                w.WriteAttributeString("GuiNumber", enc.EncryptData(sGuiID));
                w.WriteAttributeString("Serialnumber", enc.EncryptData(sSerial));
                w.WriteAttributeString("KeyRegister", enc.EncryptData(RegisterKey, sSerial + sGuiID));
                w.WriteEndElement();

                // Kết thúc tài liệu.
                w.WriteEndElement();
                w.WriteEndDocument();
                w.Flush();
                w.Close();
                fs.Close();
                return true;
            }
            catch (Exception ex)
            {

                return false;
            }
        }
        public void updateCartFile(List<CartObject> newCartObj)
        {
            bool found = false;

            string cartFile = "C:\\Users\\Kiran\\Desktop\\cart.xml";

            if (!File.Exists(cartFile))
            {
                XmlTextWriter xWriter = new XmlTextWriter(cartFile, Encoding.UTF8);
                xWriter.Formatting = Formatting.Indented;
                xWriter.WriteStartElement("carts");
                xWriter.WriteStartElement("cart");
                xWriter.WriteAttributeString("emailId", Session["emailId"].ToString());
                xWriter.Close();
            }

            XmlDocument doc = new XmlDocument();
            doc.Load(cartFile);
            foreach (CartObject cartItem in newCartObj)
            {
                foreach (XmlNode xNode in doc.SelectNodes("carts"))
                {
                    XmlNode cartNode = xNode.SelectSingleNode("cart");
                    if (cartNode.Attributes["emailId"].InnerText == Session["emailId"].ToString())
                    {
                        found = true;
                        XmlNode bookNode = doc.CreateElement("book");
                        XmlNode nameNode = doc.CreateElement("name");
                        nameNode.InnerText = cartItem.itemName;
                        XmlNode priceNode = doc.CreateElement("price");
                        priceNode.InnerText = cartItem.itemPrice.ToString();
                        XmlNode quantityNode = doc.CreateElement("quantity");
                        quantityNode.InnerText = "1";
                        bookNode.AppendChild(nameNode);
                        bookNode.AppendChild(priceNode);
                        bookNode.AppendChild(quantityNode);
                        cartNode.AppendChild(bookNode);
                    }
                }
                if(!found)
                  {
                        XmlNode cartNode = doc.CreateElement("cart");
                        cartNode.Attributes["emailId"].InnerText = Session["emailId"].ToString();
                        XmlNode bookNode = doc.CreateElement("book");
                        XmlNode nameNode = doc.CreateElement("name");
                        nameNode.InnerText = cartItem.itemName;
                        XmlNode priceNode = doc.CreateElement("price");
                        priceNode.InnerText = cartItem.itemPrice.ToString();
                        XmlNode quantityNode = doc.CreateElement("quantity");
                        quantityNode.InnerText = "1";
                        bookNode.AppendChild(nameNode);
                        bookNode.AppendChild(priceNode);
                        bookNode.AppendChild(quantityNode);
                        cartNode.AppendChild(bookNode);
                        doc.DocumentElement.AppendChild(cartNode);

                  }
                }
            doc.Save(cartFile);
        }
        private static void WriteXMLDocument(List<List<Review>> allResults)
        {
            string fileName = "../../reviews-search-results.xml";
            Encoding encoding = Encoding.GetEncoding("UTF-8");


            using (XmlTextWriter writer = new XmlTextWriter(fileName, encoding))
            {
                writer.Formatting = Formatting.Indented;
                writer.IndentChar = '\t';
                writer.Indentation = 1;

                writer.WriteStartDocument();

                writer.WriteStartElement("search-results");

                foreach (var results in allResults)
                {
                    writer.WriteStartElement("result-set");
                    var orderedResult = (from e in results
                                         orderby e.DateOfCreation
                                         select e).ToList();

                    WriteBookInXML(orderedResult, writer);
                    writer.WriteEndElement();
                }
                writer.WriteEndDocument();
            }
        }
Example #6
1
        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();
        }
Example #7
1
 // XmlWriterSample1/form.cs
 private void button1_Click(object sender, System.EventArgs e)
 {
     // change to match you path structure
     string fileName="booknew.xml";
     //create the XmlTextWriter
     XmlTextWriter tw=new XmlTextWriter(fileName,null);
     //set the formatting to indented
     tw.Formatting=Formatting.Indented;
     tw.WriteStartDocument();
     //Start creating elements and attributes
     tw.WriteStartElement("book");
     tw.WriteAttributeString("genre","Mystery");
     tw.WriteAttributeString("publicationdate","2001");
     tw.WriteAttributeString("ISBN","123456789");
     tw.WriteElementString("title","Case of the Missing Cookie");
     tw.WriteStartElement("author");
     tw.WriteElementString("name","Cookie Monster");
     tw.WriteEndElement();
     tw.WriteElementString("price","9.99");
     tw.WriteEndElement();
     tw.WriteEndDocument();
     //clean up
     tw.Flush();
     tw.Close();
 }
        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());
        }
Example #9
0
 public static void WriteXmlInFile(string layer, string msg)
 {
     try
     {
         //XmlDataDocument sourceXML = new XmlDataDocument();
         string xmlFile = HttpContext.Current.Server.MapPath("/log/Exception.xml");
         //create a XML file is not exist
         System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(xmlFile, null);
         //starts a new document
         writer.WriteStartDocument();
         //write comments
         writer.WriteComment("Commentss: XmlWriter Test Program");
         writer.Formatting = Formatting.Indented;
         writer.WriteStartElement("MessageList");
         writer.WriteStartElement("Exception");
         writer.WriteAttributeString("Layer", layer);
         //write some simple elements
         writer.WriteElementString("Message", msg);
         writer.WriteEndElement();
         writer.WriteEndElement();
         writer.WriteEndElement();
         writer.Close();
     }
     catch (Exception ex) { throw ex; }
 }
        private static void SaveManToXml(IList<Man> people)
        {
            string fileName = "../../peoples.xml";

            using (XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.GetEncoding("windows-1251")))
            {
                writer.Formatting = Formatting.Indented;
                writer.IndentChar = '\t';
                writer.Indentation = 1;

                writer.WriteStartDocument();

                writer.WriteStartElement("people");

                foreach (var man in people)
                {
                    writer.WriteStartElement("person");
                    writer.WriteElementString("name", man.Name);
                    writer.WriteElementString("address", man.Address);
                    writer.WriteElementString("phone", man.Phone);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
            }
        }
Example #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();
        }
Example #12
0
        private void SavePluginListToXMLFile(string filename)
        {
            try
            {
                Console.WriteLine("Saving plugins entries to " + (string)MediaNET.Config["Interface/plugins.xml"]);
                XmlTextWriter writer = new System.Xml.XmlTextWriter((string)MediaNET.Config["Interface/plugins.xml"], null);
                writer.Formatting = Formatting.Indented;
                writer.WriteStartDocument();
                writer.WriteStartElement("plugins");

                TreeModel model = pluginList.Model;
                TreeIter  iter;
                if (pluginStore.GetIterFirst(out iter))
                {
                    do
                    {
                        writer.WriteStartElement("plugin");
                        writer.WriteElementString("extension", (string)model.GetValue(iter, 0));
                        // Second field ignored -> found using reflection
                        writer.WriteElementString("player", (string)model.GetValue(iter, 2));
                        writer.WriteElementString("path", (string)model.GetValue(iter, 3));
                        writer.WriteEndElement();
                    }while (pluginStore.IterNext(ref iter));
                }
                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
            catch (Exception e)
            {
                throw new Exception("Save settings failed: " + e.Message);
            }
        }
Example #13
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            if (!Desc.Convex)
              MessageBox.Show("Útvar není konvexní a při detekci kolizí bude nahrazen jeho konvexním obalem.","Konvexnost",MessageBoxButtons.OK,MessageBoxIcon.Information);

            using (XmlTextWriter Object = new XmlTextWriter("objects\\" + text_objName.Text + ".xml", Encoding.UTF8))
            {
                Object.WriteStartDocument();
                Object.WriteStartElement("Geometry");
                Object.WriteAttributeString("W", Desc.Width.ToString());
                Object.WriteAttributeString("H", Desc.Height.ToString());
                Object.WriteAttributeString("D", text_objDepth.Text);
                Object.WriteAttributeString("C", text_objDrag.Text);
                Object.WriteAttributeString("Color", col);
                Object.WriteAttributeString("Tension", text_objTension.Text);
                Object.WriteAttributeString("ID", System.Guid.NewGuid().ToString());

                Object.WriteStartElement("COG");
                Object.WriteAttributeString("X", (COG.Value.X-Desc.Centroid.X).ToString());
                Object.WriteAttributeString("Y", (COG.Value.Y-Desc.Centroid.Y).ToString());
                Object.WriteEndElement();

                for (int i = 0; i < pts.Count; i++)
                {
                    Object.WriteStartElement("Vertex");
                    Object.WriteAttributeString("X", (((PointF)pts[i]).X - Desc.Centroid.X).ToString());
                    Object.WriteAttributeString("Y", (((PointF)pts[i]).Y - Desc.Centroid.Y).ToString());
                    Object.WriteEndElement();
                }

                Object.WriteEndElement();
                Object.WriteEndDocument();
            }
            Close();
        }
Example #14
0
        private static void WriteResults(
        XmlTextWriter writer, List<IEnumerable<Review>> searchResults)
        {
            writer.WriteStartElement("search-results");
            foreach (var searchSet in searchResults)
            {
                writer.WriteStartElement("result-set");
                foreach (var result in searchSet)
                {
                    writer.WriteStartElement("review");

                    if (result.DateOfCreation != null)
                    {
                        writer.WriteElementString("date", ((DateTime)result.DateOfCreation).ToString("dd-MMM-yyyy", CultureInfo.InvariantCulture));
                    }

                    if (!string.IsNullOrWhiteSpace(result.ReviewText))
                    {
                        writer.WriteElementString("content", result.ReviewText);
                    }

                    writer.WriteStartElement("book");

                    if (!string.IsNullOrWhiteSpace(result.Book.Title))
                    {
                        writer.WriteElementString("title", result.Book.Title);
                    }

                    if (result.Book.Authors != null)
                    {
                        StringBuilder allAuthors = new StringBuilder();

                        foreach (var item in result.Book.Authors)
                        {
                            allAuthors.AppendFormat("{0}, ", item.AuthorName);
                        }

                        writer.WriteElementString("authors", allAuthors.ToString().Trim(new char[] { ',', ' ' }));
                    }

                    if (!string.IsNullOrWhiteSpace(result.Book.ISBN))
                    {
                        writer.WriteElementString("isbn", result.Book.ISBN);
                    }

                    if (!string.IsNullOrWhiteSpace(result.Book.WebSite))
                    {
                        writer.WriteElementString("web-site", result.Book.WebSite);
                    }

                    writer.WriteEndElement();

                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
Example #15
0
        public static void ConvetTextToXml()
        {
            string[] lines;
            const int NumberOfTagsForEachPerson = 3;
            using (var writer = new XmlTextWriter("../../toXml.xml", Encoding.UTF8))
            {
                writer.Formatting = Formatting.Indented;
                writer.IndentChar = '\t';
                writer.Indentation = 1;

                using (StreamReader reader = new StreamReader("../../fromText.txt"))
                {
                    lines = reader.ReadToEnd().Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

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

                    for (int i = 0; i < lines.Length; i += NumberOfTagsForEachPerson)
                    {
                        writer.WriteStartElement("Person");
                        writer.WriteElementString("name", lines[i]);
                        writer.WriteElementString("adress", lines[i + 1]);
                        writer.WriteElementString("telephone", lines[i + 2]);
                        writer.WriteEndElement();
                    }

                    writer.WriteEndElement();
                }
            }

            Console.WriteLine("\tDONE!!! Check file!");
        }
Example #16
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            int dauer = 10;

            try
            {
                dauer = Convert.ToInt32(txt_dauer.Text);
            }
            catch (Exception)
            {
                
               
            }
            if (!Directory.Exists(Directory.GetCurrentDirectory() + "/quizxml/"))
            {
                Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/quizxml/"); 
            }

            if (File.Exists(Directory.GetCurrentDirectory() + "/quizxml/" + txt_name.Text + ".xml"))
            {
                if (!bearbeiten)
                {
                    MessageBox.Show("Ein Quiz mit diesem Namen existiert bereits! Bitte wählen Sie einen anderen Namen.");
                    return;  
                }                
            }
            else
            {
                XmlTextWriter myXmlTextWriter = new XmlTextWriter(Directory.GetCurrentDirectory() + "/quizxml/" + txt_name.Text + ".xml", System.Text.Encoding.UTF8);
                myXmlTextWriter.Formatting = Formatting.Indented;
                myXmlTextWriter.WriteStartDocument(false);

                myXmlTextWriter.WriteStartElement("Quiz");
                myXmlTextWriter.WriteElementString("quizname", txt_name.Text);
                myXmlTextWriter.WriteElementString("sounddatei", txt_name.Text + ".mp3");
                myXmlTextWriter.WriteElementString("clipdauer", dauer.ToString());                
                myXmlTextWriter.WriteElementString("quiztyp", lb_kato.SelectedValue.ToString());
                myXmlTextWriter.WriteStartElement("Items");
                myXmlTextWriter.WriteEndElement();
                myXmlTextWriter.WriteEndElement();
                myXmlTextWriter.Close();
                bearbeiten = true;
            }


            // index = 0 für sound
            if (lb_kato.SelectedIndex == 0)
            {
                MainWindow begriffe_window = new MainWindow(txt_name.Text);
                begriffe_window.Owner = this;
                begriffe_window.Show();
            }
            // index = 1 für text
            if (lb_kato.SelectedIndex == 1)
            {
                fragenquiz begriffe_window = new fragenquiz(txt_name.Text);
                begriffe_window.Owner = this;
                begriffe_window.Show();
            }
        }
Example #17
0
    public void Save(string fileName)
    {
      using (XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.UTF8))
      {
        writer.Formatting = Formatting.Indented;
        writer.Indentation = 1;
        writer.IndentChar = (char) 9;
        writer.WriteStartDocument(true);
        writer.WriteStartElement("menu"); // <menu>

        foreach (MenuFolder collection in _items)
        {
          writer.WriteStartElement("collection"); // <collection>
          writer.WriteAttributeString("name", collection.Name);

          foreach (string command in collection.GetAllItems())
          {
            writer.WriteStartElement("command"); // <command>
            writer.WriteAttributeString("name", collection.GetItem(command).Name);
            writer.WriteAttributeString("value", collection.GetItem(command).Command);

            writer.WriteEndElement(); // </command>
          }

          writer.WriteEndElement(); // </collection>
        }

        writer.WriteEndElement(); // </menu>
        writer.WriteEndDocument();
      }
    }
        /// <summary> 
        /// Encodes a function call to be sent to Flash. 
        /// </summary> 
        /// <param name="functionName">The name of the function to call.</param> 
        /// <param name="arguments">Zero or more parameters to pass in to the ActonScript function.</param> 
        /// <returns>The XML string representation of the function call to pass to Flash</returns> 
        public static string EncodeInvoke(string functionName, object[] arguments)
        {
            StringBuilder sb = new StringBuilder();

            XmlTextWriter writer = new XmlTextWriter(new StringWriter(sb));

            // <invoke name="functionName" returntype="xml">
            writer.WriteStartElement("invoke");
            writer.WriteAttributeString("name", functionName);
            writer.WriteAttributeString("returntype", "xml");

            if (arguments != null && arguments.Length > 0)
            {
                // <arguments>
                writer.WriteStartElement("arguments");

                // individual arguments
                foreach (object value in arguments)
                {
                    WriteElement(writer, value);
                }

                // </arguments>
                writer.WriteEndElement();
            }

            // </invoke>
            writer.WriteEndElement();

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

            return sb.ToString();
        }
Example #19
0
        /// <summary>
        /// Export a MacGui style plist preset.
        /// </summary>
        /// <param name="path">
        /// The path.
        /// </param>
        /// <param name="preset">
        /// The preset.
        /// </param>
        public static void Export(string path, Preset preset)
        {
            EncodeTask parsed = QueryParserUtility.Parse(preset.Query);
            XmlTextWriter xmlWriter = new XmlTextWriter(path, Encoding.UTF8) { Formatting = Formatting.Indented };

            // Header
            xmlWriter.WriteStartDocument();
            xmlWriter.WriteDocType("plist", "-//Apple//DTD PLIST 1.0//EN",
                                @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);

            xmlWriter.WriteStartElement("plist");
            xmlWriter.WriteStartElement("array");

            // Add New Preset Here. Can write multiple presets here if required in future.
            WritePreset(xmlWriter, parsed, preset);

            // Footer
            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndElement();

            xmlWriter.WriteEndDocument();

            // Closeout
            xmlWriter.Close();
        }
Example #20
0
        /// <summary>
        /// Saves settings to an XML file
        /// </summary>
        /// <param name="file">The file to save to</param>
        internal static void SaveSettings(string file)
        {
            try
            {
                // Open writer
                System.Xml.XmlTextWriter xmlwriter = new System.Xml.XmlTextWriter(file, System.Text.Encoding.Default);
                xmlwriter.Formatting = System.Xml.Formatting.Indented;

                // Start document
                xmlwriter.WriteStartDocument();
                xmlwriter.WriteStartElement("KMLImporter");

                // ShowAllLabels
                xmlwriter.WriteStartElement("ShowAllLabels");
                xmlwriter.WriteString(ShowAllLabels.ToString(CultureInfo.InvariantCulture));
                xmlwriter.WriteEndElement();

                // End document
                xmlwriter.WriteEndElement();
                xmlwriter.WriteEndDocument();

                // Close writer
                xmlwriter.Flush();
                xmlwriter.Close();
            }
            catch (System.IO.IOException)
            { }
            catch (System.Xml.XmlException)
            { }
        }
Example #21
0
        public static void Main()
        {
            using (XmlTextWriter writer = new XmlTextWriter("../../albums.xml", Encoding.UTF8))
            {
                writer.Formatting = Formatting.Indented;
                writer.IndentChar = '\t';
                writer.Indentation = 1;

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

                using (XmlTextReader reader = new XmlTextReader("../../catalog.xml"))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            if (reader.Name == "name")
                            {
                                writer.WriteStartElement("album");
                                writer.WriteElementString("name", reader.ReadElementString());
                            }

                            if (reader.Name == "artist")
                            {
                                writer.WriteElementString("artist", reader.ReadElementString());
                                writer.WriteEndElement();
                            }
                        }
                    }
                }

                writer.WriteEndDocument();
            }
        }
        /// <summary>
        /// Export a MacGui style plist preset.
        /// </summary>
        /// <param name="path">
        /// The path.
        /// </param>
        /// <param name="preset">
        /// The preset.
        /// </param>
        /// <param name="build">
        /// The build.PictureModulusPictureModulus
        /// </param>
        public static void Export(string path, Preset preset, string build)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            EncodeTask parsed = new EncodeTask(preset.Task);
            using (XmlTextWriter xmlWriter = new XmlTextWriter(path, Encoding.UTF8) { Formatting = Formatting.Indented })
            {
                // Header
                xmlWriter.WriteStartDocument();
                xmlWriter.WriteDocType(
                    "plist", "-//Apple//DTD PLIST 1.0//EN", @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);

                xmlWriter.WriteStartElement("plist");
                xmlWriter.WriteStartElement("array");

                // Add New Preset Here. Can write multiple presets here if required in future.
                WritePreset(xmlWriter, parsed, preset, build);

                // Footer
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndElement();

                xmlWriter.WriteEndDocument();

                // Closeout
                xmlWriter.Close();
            }
        }
Example #23
0
        private void DumpInputs()
        {
            try
            {
                System.Reflection.Assembly currentAssembly = System.Reflection.Assembly.GetAssembly(typeof(MainForm));
                FileInfo assemblyFileInfo = new FileInfo(currentAssembly.Location);

                System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(assemblyFileInfo.DirectoryName + @"\init.xml", null);

                xw.Formatting  = System.Xml.Formatting.Indented;
                xw.Indentation = 2;
                xw.WriteStartDocument();
                xw.WriteStartElement("Robocopy_GUI");


                xw.WriteStartElement("Source");
                xw.WriteString(this.textSource.Text);
                xw.WriteEndElement();

                xw.WriteStartElement("Destination");
                xw.WriteString(this.textDestination.Text);
                xw.WriteEndElement();


                xw.WriteEndElement();
                xw.WriteEndDocument();
                xw.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace, ex.Source);
            }
        }
        /// <summary>
        /// The traverse directory.
        /// </summary>
        /// <param name="directory">
        /// The directory.
        /// </param>
        public static void TraverseDirectory(string directory)
        {
            // Write a program to traverse given directory and write to a XML file its contents together with all subdirectories and files.
            var dir = new DirectoryInfo(directory);

            using (writer = new XmlTextWriter(xmlDirFilename, Encoding.UTF8))
            {
                writer.Formatting = Formatting.Indented;
                writer.IndentChar = '\t';
                writer.Indentation = 1;

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

                foreach (var file in dir.GetFiles())
                {
                    writer.WriteStartElement("file");
                    writer.WriteAttributeString("name", file.Name);
                    writer.WriteEndElement();
                }

                foreach (var subDir in dir.GetDirectories())
                {
                    CreateSubdirectoryXml(subDir);
                }

                writer.WriteEndDocument();
            }
        }
Example #25
0
        /// <summary>Serialize the <c>XmlRpcResponse</c> to the output stream.</summary>
        /// <param name="output">An <c>XmlTextWriter</c> stream to write data to.</param>
        /// <param name="obj">An <c>Object</c> to serialize.</param>
        /// <seealso cref="XmlRpcResponse"/>
        public override void Serialize(XmlTextWriter output, Object obj)
        {
            XmlRpcResponse response = (XmlRpcResponse) obj;

            output.WriteStartDocument();
            output.WriteStartElement(METHOD_RESPONSE);

            if (response.IsFault)
              output.WriteStartElement(FAULT);
            else
              {
            output.WriteStartElement(PARAMS);
            output.WriteStartElement(PARAM);
              }

            output.WriteStartElement(VALUE);

            SerializeObject(output,response.Value);

            output.WriteEndElement();

            output.WriteEndElement();
            if (!response.IsFault)
              output.WriteEndElement();
            output.WriteEndElement();
        }
Example #26
0
        /// <summary>
        ///     Export Products To Google Base
        /// </summary>
        /// <returns></returns>
        public byte[] ExportProductsToGoogleBase()
        {
            const string ns = "http://base.google.com/ns/1.0";
            var ms = new MemoryStream();
            var xml = new XmlTextWriter(ms, Encoding.UTF8);

            xml.WriteStartDocument();
            xml.WriteStartElement("rss");
            xml.WriteAttributeString("xmlns", "g", null, ns);
            xml.WriteAttributeString("version", "2.0");
            xml.WriteStartElement("channel");

            //GENERAL FEED INFO
            xml.WriteElementString("title", CurrentRequestData.CurrentSite.Name);
            xml.WriteElementString("link", CurrentRequestData.CurrentSite.BaseUrl);
            xml.WriteElementString("description",
                " Products from " + CurrentRequestData.CurrentSite.Name + " online store");

            IList<ProductVariant> productVariants = _productVariantService.GetAllVariantsForGoogleBase();

            foreach (ProductVariant pv in productVariants)
            {
                ExportGoogleBaseProduct(ref xml, pv, ns);
            }

            xml.WriteEndElement();
            xml.WriteEndElement();
            xml.WriteEndDocument();

            xml.Flush();
            byte[] file = ms.ToArray();
            xml.Close();

            return file;
        }
        /// <summary>
        /// Adds a single item to the XmlTextWriter supplied
        /// </summary>
        /// <param name="writer">The XmlTextWriter to be written to</param>
        /// <param name="sItemTitle">The title of the RSS item</param>
        /// <param name="sItemLink">The URL of the RSS item</param>
        /// <param name="sItemDescription">The RSS item text itself</param>
        /// <param name="sPubDate"></param>
        /// <param name="bDescAsCdata">Write description as CDATA</param>
        /// <returns>The XmlTextWriter with the item info written to it</returns>
        public XmlTextWriter AddRssItem(XmlTextWriter writer, string sItemTitle, string sItemLink, string sItemDescription, DateTime sPubDate, bool bDescAsCdata)
        {
            writer.WriteStartElement("item");
            writer.WriteElementString("title", sItemTitle);
            writer.WriteElementString("link", sItemLink);

            if (bDescAsCdata)
            {
                // Now we can write the description as CDATA to support html content.
                // We find this used quite often in aggregators

                writer.WriteStartElement("description");
                writer.WriteCData(sItemDescription);
                writer.WriteEndElement();
            }
            else
            {
                writer.WriteElementString("description", sItemDescription);
            }

            writer.WriteElementString("pubDate", sPubDate.ToString("r"));
            writer.WriteEndElement();

            return writer;
        }
Example #28
0
        private void WriteFeed(IEnumerable<DonaldEpisode> episodes, Stream responseStream, string url)
        {
            XmlTextWriter objX = new XmlTextWriter(responseStream, Encoding.UTF8);
            objX.WriteStartDocument();
            objX.WriteStartElement("rss");
            objX.WriteAttributeString("version", "2.0");
            objX.WriteStartElement("channel");
            objX.WriteElementString("title", "Donald Inc.");
            objX.WriteElementString("link", url);
            objX.WriteElementString("description",
                                    "Your custom donald feed!");
            objX.WriteElementString("copyright", "(c) 2011, Chuck Norris.");
            objX.WriteElementString("ttl", "5");
            foreach (var episode in episodes)
            {
                objX.WriteStartElement("item");
                objX.WriteElementString("title", episode.Title);
                objX.WriteElementString("description", episode.Content);
                objX.WriteElementString("link",
                                        Configuration.ApiUri + "/" + episode.Id);
                objX.WriteElementString("pubDate", episode.ReleaseDate.Value.ToString("R"));
                objX.WriteStartElement("enclosure");
                objX.WriteAttributeString("url", Configuration.ApiUri + "/" + episode.Id + "/jpg");
                objX.WriteAttributeString("type", "application/jpg");
                objX.WriteEndElement();
                objX.WriteEndElement();
            }

            objX.WriteEndElement();
            objX.WriteEndElement();
            objX.WriteEndDocument();
            objX.Flush();
        }
 private static void PingServices(IEnumerable<Uri> Services, Uri Blog, string BlogName)
 {
     foreach (Uri Service in Services)
     {
         HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(Service);
         Request.Credentials = CredentialCache.DefaultNetworkCredentials;
         Request.ContentType = "text/xml";
         Request.Method = "POST";
         Request.Timeout = 10000;
         using (XmlTextWriter XMLWriter = new XmlTextWriter(Request.GetRequestStream(), Encoding.ASCII))
         {
             XMLWriter.WriteStartDocument();
             XMLWriter.WriteStartElement("methodCall");
             XMLWriter.WriteElementString("methodName", "weblogUpdates.ping");
             XMLWriter.WriteStartElement("params");
             XMLWriter.WriteStartElement("param");
             XMLWriter.WriteElementString("value", BlogName);
             XMLWriter.WriteEndElement();
             XMLWriter.WriteStartElement("param");
             XMLWriter.WriteElementString("value", Blog.ToString());
             XMLWriter.WriteEndElement();
             XMLWriter.WriteEndElement();
             XMLWriter.WriteEndElement();
         }
     }
 }
Example #30
0
        public void CreateXml()
        {
            if ( ( m_SeasonList.Count > 0 ) )
            {
                const string fileName = "NFL.xml";
                XmlTextWriter writer = new
                    XmlTextWriter(string.Format("{0}{1}", Utility.OutputDirectory() + "xml\\", fileName), null);
                writer.Formatting = Formatting.Indented;

                writer.WriteStartDocument();
                writer.WriteComment( "Comments: NFL Season List" );
                writer.WriteStartElement( "nfl" );
                writer.WriteStartElement("season-list");

                foreach ( NflSeason s in m_SeasonList )
                {
                    WriteSeasonNode( writer, s );
                }
                writer.WriteEndElement();
                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Close();
                RosterLib.Utility.Announce( fileName + " created" );
            }
        }
		public override void SaveSettings()
		{
            if (!this.writeable)
                throw new InvalidOperationException("Attempted to write to a non-writeable Settings Storage");

			string dirPath = Path.GetDirectoryName( filePath );
			if ( !Directory.Exists( dirPath ) )
				Directory.CreateDirectory( dirPath );

			XmlTextWriter writer = new XmlTextWriter(  filePath, System.Text.Encoding.UTF8 );
			writer.Formatting = Formatting.Indented;

			writer.WriteProcessingInstruction( "xml", "version=\"1.0\"" );
			writer.WriteStartElement( "NUnitSettings" );
			writer.WriteStartElement( "Settings" );

			ArrayList keys = new ArrayList( settings.Keys );
			keys.Sort();

			foreach( string name in keys )
			{
				object val = settings[name];
				if ( val != null )
				{
					writer.WriteStartElement( "Setting");
					writer.WriteAttributeString( "name", name );
					writer.WriteAttributeString( "value", val.ToString() );
					writer.WriteEndElement();
				}
			}

			writer.WriteEndElement();
			writer.WriteEndElement();
			writer.Close();
		}
        static void Main(string[] args)
        {
            using (XmlTextWriter writer = new XmlTextWriter(OutputPath, Encoding.UTF8))
            {
                writer.Formatting = Formatting.Indented;
                writer.Indentation = 4;
                writer.IndentChar = ' ';
                writer.WriteStartDocument();
                writer.WriteStartElement("albums");

                using (XmlReader reader = XmlReader.Create(InputPath))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            if (reader.Name == "name")
                            {
                                writer.WriteStartElement("album");
                                writer.WriteElementString("name", reader.ReadElementString());
                            }
                            else if (reader.Name == "artist")
                            {
                                writer.WriteElementString("artist", reader.ReadElementString());
                                writer.WriteEndElement();
                            }
                        }
                    }
                }

                writer.WriteEndDocument();
            }

            Console.WriteLine("Parsing is finished. Your document is ready.");
        }
Example #33
0
        private void GenerateDescription(string host = null)
        {
            MemoryStream memStream = new MemoryStream();
            using (XmlTextWriter descWriter = new XmlTextWriter(memStream, new UTF8Encoding(false)))
            {
                descWriter.Formatting = Formatting.Indented;
                descWriter.WriteRaw("<?xml version=\"1.0\"?>");

                descWriter.WriteStartElement("root", "urn:schemas-upnp-org:device-1-0");

                descWriter.WriteStartElement("specVersion");
                descWriter.WriteElementString("major", "1");
                descWriter.WriteElementString("minor", "0");
                descWriter.WriteEndElement();

                descWriter.WriteStartElement("device");
                rootDevice.WriteDescription(descWriter, host);
                descWriter.WriteEndElement();

                descWriter.WriteEndElement();

                descWriter.Flush();
                descArray = memStream.ToArray();
            }
        }
Example #34
0
 public static void CreateXml(string path)
 {
     XmlTextWriter writer = new XmlTextWriter(path, Encoding.UTF8) {
         Formatting = Formatting.Indented
     };
     writer.WriteStartDocument();
     writer.WriteStartElement("root");
     for (int i = 0; i < 5; i++)
     {
         writer.WriteStartElement("Node");
         writer.WriteAttributeString("Text", "这是文章内容!~!!~~");
         writer.WriteAttributeString("ImageUrl", "");
         writer.WriteAttributeString("NavigateUrl", "Url..." + i.ToString());
         writer.WriteAttributeString("Expand", "true");
         for (int j = 0; j < 5; j++)
         {
             writer.WriteStartElement("Node");
             writer.WriteAttributeString("Text", "......名称");
             writer.WriteAttributeString("NavigateUrl", "Url..." + i.ToString());
             writer.WriteEndElement();
         }
         writer.WriteEndElement();
     }
     writer.WriteFullEndElement();
     writer.Close();
 }
Example #35
0
    /// <summary>
    /// Writes elements to an xml writer
    /// </summary>
    /// <param name="writer"></param>
    private void WriteElements(Xml.XmlTextWriter writer)
    {
        // iterate across all keys in this section and write them to the xml file
        IDictionaryEnumerator enumerator = this.keyTable.GetEnumerator();

        while (enumerator.MoveNext())
        {
            writer.WriteStartElement(keyName);
            writer.WriteAttributeString("name", (string)enumerator.Key);
            writer.WriteString((string)enumerator.Value);

//			System.Diagnostics.Debug.WriteLine(
//"Wrote: " + this.name + " " + (string)enumerator.Key + " = " + (string)enumerator.Value);

            writer.WriteEndElement();
        }

        // then do it for all sub sections
        foreach (XmlStorage xml in this.subsectionTable.Values)
        {
            writer.WriteStartElement(subsectionName);
            writer.WriteAttributeString("name", xml.name);

            xml.WriteElements(writer);

            writer.WriteEndElement();
        }
    }
Example #36
0
        public override string Serialize(Node node, Type typeAttr)
        {
            XpcaProxy proxy = new XpcaProxy(node);
            StringWriter sw = new StringWriter();

            using(XmlWriter xmlWriter = new XmlTextWriter(sw))
            {
                xmlWriter.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");
                xmlWriter.WriteStartElement("root");
                foreach (KeyValuePair<string, PropertyInfo> property in proxy.GetPropertiesFor(typeAttr)) {

                    object value = proxy[property.Key];
                    if (value != null) {
                        xmlWriter.WriteStartElement(property.Key);
                        if(value is IEnumerable<object>) {
                            foreach (object obj in (value as IEnumerable<object>)) {
                                xmlWriter.WriteStartElement("item");
                                XmlWriteValue(xmlWriter, obj);
                                xmlWriter.WriteEndElement();
                            }

                        }
                        else {
                            XmlWriteValue(xmlWriter, value);
                        }
                        xmlWriter.WriteEndElement();
                    }
                }
                xmlWriter.WriteEndElement();
            }

            return sw.ToString();
        }
Example #37
0
        private void writeGPX(string filename)
        {
            System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(filename) + ".gpx", Encoding.ASCII);

            xw.WriteStartElement("gpx");

            xw.WriteStartElement("trk");

            xw.WriteStartElement("trkseg");

            foreach (CurrentState cs in flightdata)
            {
                xw.WriteStartElement("trkpt");
                xw.WriteAttributeString("lat", cs.lat.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteAttributeString("lon", cs.lng.ToString(new System.Globalization.CultureInfo("en-US")));

                xw.WriteElementString("ele", cs.alt.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteElementString("time", cs.datetime.ToString("yyyy-MM-ddTHH:mm:sszzzzzz"));
                xw.WriteElementString("course", (cs.yaw).ToString(new System.Globalization.CultureInfo("en-US")));

                xw.WriteElementString("roll", cs.roll.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteElementString("pitch", cs.pitch.ToString(new System.Globalization.CultureInfo("en-US")));
                //xw.WriteElementString("speed", mod.model.Orientation.);
                //xw.WriteElementString("fix", cs.altitude);

                xw.WriteEndElement();
            }

            xw.WriteEndElement();
            xw.WriteEndElement();
            xw.WriteEndElement();

            xw.Close();
        }
Example #38
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 virtual void SaveToXml(System.Xml.XmlTextWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("ReferenceFrame");
            xmlWriter.WriteAttributeString("Name", Name);
            xmlWriter.WriteAttributeString("Parent", Parent);
            xmlWriter.WriteAttributeString("ReferenceFrameType", ReferenceFrameType.ToString());
            xmlWriter.WriteAttributeString("Reference", Reference.ToString());
            xmlWriter.WriteAttributeString("ParentsRoationalBase", ParentsRoationalBase.ToString());
            xmlWriter.WriteAttributeString("MeanRadius", MeanRadius.ToString());
            xmlWriter.WriteAttributeString("Oblateness", Oblateness.ToString());
            xmlWriter.WriteAttributeString("Heading", Heading.ToString());
            xmlWriter.WriteAttributeString("Pitch", Pitch.ToString());
            xmlWriter.WriteAttributeString("Roll", Roll.ToString());
            xmlWriter.WriteAttributeString("Scale", Scale.ToString());
            xmlWriter.WriteAttributeString("Tilt", Tilt.ToString());
            xmlWriter.WriteAttributeString("Translation", Translation.ToString());
            if (ReferenceFrameType == ReferenceFrameTypes.FixedSherical)
            {
                xmlWriter.WriteAttributeString("Lat", Lat.ToString());
                xmlWriter.WriteAttributeString("Lng", Lng.ToString());
                xmlWriter.WriteAttributeString("Altitude", Altitude.ToString());
            }
            xmlWriter.WriteAttributeString("RotationalPeriod", RotationalPeriod.ToString());
            xmlWriter.WriteAttributeString("ZeroRotationDate", ZeroRotationDate.ToString());
            xmlWriter.WriteAttributeString("RepresentativeColor", SavedColor.Save(RepresentativeColor));
            xmlWriter.WriteAttributeString("ShowAsPoint", ShowAsPoint.ToString());
            xmlWriter.WriteAttributeString("ShowOrbitPath", ShowOrbitPath.ToString());

            xmlWriter.WriteAttributeString("StationKeeping", StationKeeping.ToString());

            if (ReferenceFrameType == ReferenceFrameTypes.Orbital)
            {
                xmlWriter.WriteAttributeString("SemiMajorAxis", SemiMajorAxis.ToString());
                xmlWriter.WriteAttributeString("SemiMajorAxisScale", this.SemiMajorAxisUnits.ToString());
                xmlWriter.WriteAttributeString("Eccentricity", Eccentricity.ToString());
                xmlWriter.WriteAttributeString("Inclination", Inclination.ToString());
                xmlWriter.WriteAttributeString("ArgumentOfPeriapsis", ArgumentOfPeriapsis.ToString());
                xmlWriter.WriteAttributeString("LongitudeOfAscendingNode", LongitudeOfAscendingNode.ToString());
                xmlWriter.WriteAttributeString("MeanAnomolyAtEpoch", MeanAnomolyAtEpoch.ToString());
                xmlWriter.WriteAttributeString("MeanDailyMotion", MeanDailyMotion.ToString());
                xmlWriter.WriteAttributeString("Epoch", Epoch.ToString());
            }

            if (ReferenceFrameType == ReferenceFrameTypes.Trajectory)
            {
                xmlWriter.WriteStartElement("Trajectory");

                foreach (TrajectorySample sample in Trajectory)
                {
                    string data = sample.ToString();
                    xmlWriter.WriteElementString("Sample", data);
                }
                xmlWriter.WriteEndElement();
            }

            xmlWriter.WriteEndElement();
        }
Example #40
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);
        }
Example #41
0
        /// <summary>
        /// 从DataTable和对应的GroupBox中的内容得到XML串
        /// </summary>
        /// <param name="p_objclsElementAttributeArr">p_dtbTable列数 ==p_objclsElementAttributeArr的长度(GroupBox中各项+签名+时间,每项对应一个clsElementAttribute对象)</param>
        /// <param name="p_dtbTable">记录对应的DataTable</param>
        /// <param name="p_objXmlMemStream"></param>
        /// <param name="p_xmlWriter"></param>
        /// <returns>若参数错误返回null</returns>
        public string m_strGetXMLFromDataTable(clsElementAttribute[] p_objclsElementAttributeArr, System.Data.DataTable p_dtbTable, ref System.IO.MemoryStream p_objXmlMemStream, ref System.Xml.XmlTextWriter p_xmlWriter)
        {
            if (p_objclsElementAttributeArr == null || p_dtbTable.Columns.Count != p_objclsElementAttributeArr.Length)
            {
                return(null);
            }

            p_objXmlMemStream.SetLength(0);
            p_xmlWriter.WriteStartDocument();
            p_xmlWriter.WriteStartElement("Main");

            clsElementAttribute objclsElementAttribute = new clsElementAttribute();

            bool blnIsModified = m_blnIsModified(p_objclsElementAttributeArr, p_dtbTable);

            if (blnIsModified == true)         //如果被修改,添加当前值
            {
                p_xmlWriter.WriteStartElement("Sub");
                for (int j0 = 0; j0 < p_objclsElementAttributeArr.Length; j0++)
                {
                    m_mthAddElementAttibute(p_objclsElementAttributeArr[j0], ref p_xmlWriter);
                }
                p_xmlWriter.WriteEndElement();
            }
            for (int i1 = 0; i1 < p_dtbTable.Rows.Count; i1++)     //重写原来的痕迹
            {
                p_xmlWriter.WriteStartElement("Sub");
                for (int j2 = 0; j2 < p_objclsElementAttributeArr.Length; j2++)
                {
                    objclsElementAttribute.m_blnIsDST       = p_objclsElementAttributeArr[j2].m_blnIsDST;            //默认为非DST格式,即为bool类型
                    objclsElementAttribute.m_strElementName = p_objclsElementAttributeArr[j2].m_strElementName;
                    if (objclsElementAttribute.m_blnIsDST == false)
                    {
                        objclsElementAttribute.m_strValue = p_dtbTable.Rows[i1][j2].ToString();
                    }
                    else
                    {
                        objclsElementAttribute.m_strValue    = ((clsDSTRichTextBoxValue)(p_dtbTable.Rows[i1][j2])).m_strText;
                        objclsElementAttribute.m_strValueXML = ((clsDSTRichTextBoxValue)(p_dtbTable.Rows[i1][j2])).m_strDSTXml;
                    }

                    m_mthAddElementAttibute(objclsElementAttribute, ref p_xmlWriter);
                }
                p_xmlWriter.WriteEndElement();
            }

            p_xmlWriter.WriteEndElement();
            p_xmlWriter.WriteEndDocument();
            p_xmlWriter.Flush();
            return(System.Text.Encoding.Unicode.GetString(p_objXmlMemStream.ToArray(), 39 * 2, (int)p_objXmlMemStream.Length - 39 * 2));
        }
Example #42
0
        public override void WriteXmlNodes(System.Xml.XmlTextWriter xmlFile)
        {
            xmlFile.WriteStartElement("Category");
            xmlFile.WriteString(Category);
            xmlFile.WriteEndElement();

            //write out all the cards
            xmlFile.WriteStartElement("Cards");
            foreach (var card in Cards)
            {
                card.WriteXmlNodes(xmlFile);
            }
            xmlFile.WriteEndElement();
        }
Example #43
0
        internal void SaveToXml(System.Xml.XmlTextWriter xmlWriter, string elementName)
        {
            xmlWriter.WriteStartElement(elementName);
            xmlWriter.WriteAttributeString("Name", name);
            xmlWriter.WriteAttributeString("DataSetType", this.Type.ToString());
            if (this.Type == ImageSetType.Sky)
            {
                xmlWriter.WriteAttributeString("RA", camParams.RA.ToString());
                xmlWriter.WriteAttributeString("Dec", camParams.Dec.ToString());
            }
            else
            {
                xmlWriter.WriteAttributeString("Lat", Lat.ToString());
                xmlWriter.WriteAttributeString("Lng", Lng.ToString());
            }

            xmlWriter.WriteAttributeString("Constellation", constellation);
            xmlWriter.WriteAttributeString("Classification", Classification.ToString());
            xmlWriter.WriteAttributeString("Magnitude", magnitude.ToString());
            xmlWriter.WriteAttributeString("Distance", distnace.ToString());
            xmlWriter.WriteAttributeString("AngularSize", AngularSize.ToString());
            xmlWriter.WriteAttributeString("ZoomLevel", ZoomLevel.ToString());
            xmlWriter.WriteAttributeString("Rotation", camParams.Rotation.ToString());
            xmlWriter.WriteAttributeString("Angle", camParams.Angle.ToString());
            xmlWriter.WriteAttributeString("Opacity", camParams.Opacity.ToString());
            xmlWriter.WriteAttributeString("Target", Target.ToString());
            xmlWriter.WriteAttributeString("ViewTarget", camParams.ViewTarget.ToString());
            xmlWriter.WriteAttributeString("TargetReferenceFrame", camParams.TargetReferenceFrame);
            xmlWriter.WriteAttributeString("DomeAlt", camParams.DomeAlt.ToString());
            xmlWriter.WriteAttributeString("DomeAz", camParams.DomeAz.ToString());
            xmlWriter.WriteStartElement("Description");
            xmlWriter.WriteCData(HtmlDescription);
            xmlWriter.WriteEndElement();


            if (backgroundImageSet != null)
            {
                xmlWriter.WriteStartElement("BackgroundImageSet");
                ImageSetHelper.SaveToXml(xmlWriter, backgroundImageSet, "");
                xmlWriter.WriteEndElement();
            }

            if (studyImageset != null)
            {
                ImageSetHelper.SaveToXml(xmlWriter, studyImageset, "");
            }
            xmlWriter.WriteEndElement();
        }
Example #44
0
        private static void SaveXMLDictionarySettings <T>(XmlSerializableDictionary <string, T> Dic, String FilePath)
        {
            try
            {
                var tmpFile = FilePath + ".tmp";
                lock (Dic)
                {
                    using (System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(tmpFile, Encoding.UTF8))
                    {
                        xtw.Formatting = Formatting.Indented;
                        xtw.WriteStartDocument();
                        xtw.WriteStartElement("dictionary");

                        Dic.WriteXml(xtw);
                        xtw.WriteEndElement();
                    }
                    if (File.Exists(FilePath))
                    {
                        File.Replace(tmpFile, FilePath, FilePath + ".backup", true);
                    }
                    else
                    {
                        File.Move(tmpFile, FilePath);
                    }
                    LastFileRead = GetLastFileModificationUTC(FilePath);
                }
            }
            catch (IOException e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
                throw;
            }
        }
Example #45
0
        public void WriteValue(string strSection, string strKey, string strValue)
        {
            //XmlNodeList mNode = mXml.GetElementsByTagName(strSection);
            XmlTextWriter mXmlWrite = new System.Xml.XmlTextWriter(this.strPathOfXml, System.Text.UTF8Encoding.UTF8);

            mXmlWrite.Formatting = Formatting.Indented;
            mXmlWrite.WriteStartDocument();
            mXmlWrite.WriteStartElement("property");
            mXmlWrite.WriteStartElement(strSection);
            mXmlWrite.WriteElementString(strKey, strValue);
            mXmlWrite.WriteEndElement();
            mXmlWrite.WriteEndElement();
            mXmlWrite.WriteEndDocument();
            mXmlWrite.Flush();
            mXmlWrite.Close();
        }
Example #46
0
        static int vipID; // = 0;

        static void SerializeVisual(Visual visual, double width, double height, String filename)
        {
            FileStream    stream = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite);
            XmlTextWriter writer = new System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8);

            writer.Formatting  = System.Xml.Formatting.Indented;
            writer.Indentation = 4;
            writer.WriteStartElement("FixedDocument");
            writer.WriteAttributeString("xmlns", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
            writer.WriteAttributeString("xmlns:x", "http://schemas.microsoft.com/winfx/2006/xaml");

            writer.WriteStartElement("PageContent");
            writer.WriteStartElement("FixedPage");
            writer.WriteAttributeString("Width", width.ToString(CultureInfo.InvariantCulture));
            writer.WriteAttributeString("Height", height.ToString(CultureInfo.InvariantCulture));
            writer.WriteAttributeString("Background", "White");
            writer.WriteStartElement("Canvas");

            System.IO.StringWriter resString = new StringWriter(CultureInfo.InvariantCulture);

            System.Xml.XmlTextWriter resWriter = new System.Xml.XmlTextWriter(resString);
            resWriter.Formatting  = System.Xml.Formatting.Indented;
            resWriter.Indentation = 4;

            System.IO.StringWriter bodyString = new StringWriter(CultureInfo.InvariantCulture);

            System.Xml.XmlTextWriter bodyWriter = new System.Xml.XmlTextWriter(bodyString);
            bodyWriter.Formatting  = System.Xml.Formatting.Indented;
            bodyWriter.Indentation = 4;

            VisualTreeFlattener.SaveAsXml(visual, resWriter, bodyWriter, filename);

            resWriter.Close();
            bodyWriter.Close();

            writer.Flush();
            writer.WriteRaw(resString.ToString());
            writer.WriteRaw(bodyString.ToString());

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

            writer.WriteEndElement(); // FixedDocument
            writer.Close();
            stream.Close();
        }
        public static string GenerateEntityXml(string outputPath, EntityInfo entity)
        {
            string ret = String.Empty;

            if (entity == null || !Directory.Exists(outputPath))
            {
                return(ret);
            }

            Log4Helper.Write("GenerateEntityXml", String.Format("Process of entity {0} starts at {1}.", entity.ClassName, System.DateTime.Now.ToString("s")), LogSeverity.Info);

            using (System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(System.IO.Path.Combine(outputPath, String.Concat(entity.ClassName, ".xml")), System.Text.Encoding.UTF8))
            {
                xtw.Formatting = System.Xml.Formatting.Indented;
                xtw.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");

                //generate entity calss
                xtw.WriteStartElement("entity");
                xtw.WriteAttributeString("namespace", entity.NameSpace);
                xtw.WriteAttributeString("name", entity.ClassName);

                #region columns/properties
                //generate property node
                xtw.WriteStartElement("fields");
                foreach (FieldInfo field in entity.Fileds)
                {
                    xtw.WriteStartElement("property");
                    xtw.WriteAttributeString("type", field.Type);
                    xtw.WriteAttributeString("name", field.Name);
                    xtw.WriteAttributeString("privateFieldName", field.PrivateFieldName);
                    xtw.WriteAttributeString("paramName", field.ParamName);
                    xtw.WriteAttributeString("propetyName", field.PropertyName);
                    xtw.WriteAttributeString("csharpType", field.CSharpType);
                    xtw.WriteEndElement();
                }
                xtw.WriteEndElement();
                #endregion
                ret = xtw.ToString();
                xtw.WriteEndElement();
                xtw.Flush();
                xtw.Close();
            }

            Log4Helper.Write("GenerateEntityXmlFromTable", String.Format("Process of table {0} ends at {1}.", entity.ClassName, System.DateTime.Now.ToString("s")), LogSeverity.Info);
            return(ret);
        }
Example #48
0
        /// <summary>
        /// creates logfile
        /// </summary>
        private void open()
        {
            if (this.opened_)
            {
                return;
            }
            try
            {
                if (theSwitch.Level > TraceLevel.Off)
                {
                    xmlwriter            = new System.Xml.XmlTextWriter(this.file_path, null);
                    xmlwriter.Formatting = System.Xml.Formatting.Indented;
                    xmlwriter.WriteStartDocument();
                    //Write the ProcessingInstruction node.
                    string PItext = theSwitch.style_instruction_pitext(string.Empty);
                    if (PItext != string.Empty)
                    {
                        xmlwriter.WriteProcessingInstruction("xml-stylesheet", PItext);
                    }

                    xmlwriter.WriteStartElement("trace");
                    xmlwriter.WriteAttributeString("timestamp", timestamp());
                    xmlwriter.WriteAttributeString("assembly", this.asm.FullName);
                    xmlwriter.WriteStartElement("switch");
                    // xmlwriter.WriteAttributeString( "displayname" , theSwitch.DisplayName) ;
                    // xmlwriter.WriteAttributeString( "description" , theSwitch.Description ) ;
                    xmlwriter.WriteAttributeString("level", theSwitch.Level.ToString());
                    xmlwriter.WriteEndElement();                     // close 'switch'
                }
                this.opened_ = true;
            }
            catch (Exception x)
            {
                evlog.internal_log.error(x); x = null;
            }
            finally
            {
                if (this.xmlwriter != null)
                {
                    xmlwriter.Close();
                }
                this.xmlwriter = null;
            }
        }
Example #49
0
        public void Save(System.Xml.XmlTextWriter tw, string localName)
        {
            tw.WriteStartElement(localName);
            tw.WriteAttributeString("Version", "1");

            tw.WriteElementString("DirectionRecentFirst", System.Xml.XmlConvert.ToString(_viewDirectionRecentIsFirst));

            tw.WriteStartElement("ColumnWidths");
            var colWidths = null != _view ? _view.ColumnWidths : new double[0];

            tw.WriteAttributeString("Count", XmlConvert.ToString(colWidths.Length));
            for (int i = 0; i < colWidths.Length; i++)
            {
                tw.WriteElementString("Width", XmlConvert.ToString(colWidths[i]));
            }
            tw.WriteEndElement(); // "ColumnWidths"

            tw.WriteEndElement(); // localName
        }
Example #50
0
 /// <summary>
 /// 添加元素属性
 /// </summary>
 /// <param name="p_objclsElementAttribute"></param>
 /// <param name="p_xmlWriter"></param>
 private void m_mthAddElementAttibute(clsElementAttribute p_objclsElementAttribute, ref System.Xml.XmlTextWriter p_xmlWriter)
 {
     p_xmlWriter.WriteStartElement(p_objclsElementAttribute.m_strElementName);
     p_xmlWriter.WriteAttributeString("VALUE", p_objclsElementAttribute.m_strValue);
     if (p_objclsElementAttribute.m_blnIsDST == true)
     {
         p_xmlWriter.WriteAttributeString("VALUEXML", p_objclsElementAttribute.m_strValueXML);
     }
     p_xmlWriter.WriteEndElement();
 }
Example #51
0
        /// <summary>
        /// 格式化日期类型
        /// </summary>
        /// <param name="doc"></param>
        /// <returns></returns>
        private XmlDocument DateTimeFormat(XmlDocument doc, List <string> eles)
        {
            if (eles == null || eles.Count == 0 || doc == null)
            {
                return(doc);
            }
            XmlDocument newDoc = new XmlDocument();

            try {
                // 建立一个 XmlTextReader 对象来读取 XML 数据。
                using (XmlTextReader myXmlReader = new XmlTextReader(doc.OuterXml, XmlNodeType.Element, null)) {
                    // 使用指定的文件与编码方式来建立一个 XmlTextWriter 对象。
                    using (System.Xml.XmlTextWriter myXmlWriter = new System.Xml.XmlTextWriter(_filePath, Encoding.UTF8)) {
                        myXmlWriter.Formatting  = Formatting.Indented;
                        myXmlWriter.Indentation = 4;
                        myXmlWriter.WriteStartDocument();

                        string elementName = "";

                        // 解析并显示每一个节点。
                        while (myXmlReader.Read())
                        {
                            switch (myXmlReader.NodeType)
                            {
                            case XmlNodeType.Element:
                                myXmlWriter.WriteStartElement(myXmlReader.Name);
                                myXmlWriter.WriteAttributes(myXmlReader, true);
                                elementName = myXmlReader.Name;

                                break;

                            case XmlNodeType.Text:
                                if (eles.Contains(elementName))
                                {
                                    myXmlWriter.WriteString(XmlConvert.ToDateTime(myXmlReader.Value, XmlDateTimeSerializationMode.Local).ToString("yyyy-MM-dd HH:mm:ss"));
                                    break;
                                }
                                myXmlWriter.WriteString(myXmlReader.Value);
                                break;

                            case XmlNodeType.EndElement:
                                myXmlWriter.WriteEndElement();
                                break;
                            }
                        }
                    }
                }
                newDoc.Load(_filePath);
                return(newDoc);
            } catch (Exception ex) {
                MessageBoxPLM.Show(string.Format("导入ERP文件格式化失败,错误信息:{0}", ex.Message));
                return(null);
            }
        }
Example #52
0
        ///<summary>
        /// SyggestSync is a goodies to ask a proper sync of what's
        /// present in RAM, and what's present in the XML file.
        ///</summary>
        public void SuggestSync()
        {
            XmlTextWriter writer = new System.Xml.XmlTextWriter("configuration.xml", null);

            writer.Formatting = Formatting.Indented;
            writer.WriteStartDocument();
            writer.WriteStartElement("entries");

            foreach (string key in m_Matches.Keys)
            {
                writer.WriteStartElement("entry");
                writer.WriteElementString("key", key);
                writer.WriteElementString("value", (string)m_Matches[key]);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Flush();
            writer.Close();
        }
Example #53
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            thread_showSth();
            txtMsg.Text = "";

            xmlWriter            = new XmlTextWriter(Server.MapPath("./1234.xml"), System.Text.Encoding.UTF8);
            xmlWriter.Formatting = Formatting.Indented;
            xmlWriter.WriteStartDocument();
            xmlWriter.WriteStartElement("队列");
            xmlWriter.WriteStartElement("跳舞");
            xmlWriter.WriteString("boy,girl");
            xmlWriter.WriteEndElement();
            //写文档结束,调用WriteEndDocument方法
            xmlWriter.WriteEndDocument();
            // 关闭textWriter
            xmlWriter.Close();
        }
    }
        protected override void WriteSettings(string fileName)
        {
            using (System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(fileName, Encoding.UTF8))
            {
                xtw.Formatting = Formatting.Indented;
                xtw.WriteStartDocument();
                xtw.WriteStartElement("dictionary");

                EncodedNameMap.WriteXml(xtw);
                xtw.WriteEndElement();
            }
        }
        public override void Save(System.Xml.XmlTextWriter xmlWriter)
        {
            xmlWriter.WriteStartElement(typeof(WorkspacesDock).Name);
            xmlWriter.WriteAttributeString("Count", _workSpaceManager.WorkSpacesCount().ToString(CultureInfo.InvariantCulture));

            foreach (IWorkSpaceShell workSpaceShell in WorkSpaceManager())
            {
                workSpaceShell.Save(xmlWriter);
            }

            xmlWriter.WriteEndElement();
        }
Example #56
0
        public void Serialize(System.Xml.XmlTextWriter xtw)
        {
            xtw.WriteStartElement(m_Property.Name.ToLower());

            foreach (Parameter param in m_Property.Parameters)
            {
                xtw.WriteAttributeString(param.Name.ToLower(), string.Join(",", param.Values.ToArray()));
            }

            xtw.WriteString(SerializeToString());

            xtw.WriteEndElement();
        }
Example #57
0
        /// <summary>
        /// GenerateEntityXmlFromTable generates a xml file basing on the information of the table passed in.
        /// </summary>
        public static void GenerateEntityXmlFromTable(Table table, ArrayList columns, ArrayList extSettings, string outputFile)
        {
            if (table != null && System.IO.File.Exists(outputFile))
            {
                System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(outputFile, System.Text.Encoding.UTF8);
                xtw.Formatting = System.Xml.Formatting.Indented;
                xtw.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");

                //generate entity calss
                xtw.WriteStartElement("entity");
                xtw.WriteAttributeString("tableName", table.TableName);
                xtw.WriteAttributeString("tableSchema", table.TableSchema);
                if (extSettings != null)
                {
                    foreach (ExtSetting e in extSettings)
                    {
                        xtw.WriteAttributeString(e.Name, e.Value);
                    }
                }
//					xtw.WriteAttributeString("namespace", codeNamespace);
//                    xtw.WriteAttributeString("author", Utility.GetCurrentIdentityName());
//                    xtw.WriteAttributeString("createdDateTime", System.DateTime.Now.ToString("s"));
                xtw.WriteAttributeString("BuildProject", BUILDPROJECT_VERSION);

                #region columns/properties
                //generate property node
                xtw.WriteStartElement("columns");
                for (int i = 0; i < columns.Count; i++)
                {
                    GenerateXmlElementFromColumn((Column)columns[i], xtw);
                }
                xtw.WriteEndElement();
                #endregion

                xtw.WriteEndElement();
                xtw.Flush();
                xtw.Close();
            }
        }
Example #58
0
        private static void WriteStep(Xml.XmlTextWriter writer, Chunk chunk)
        {
            // First write out the chunk itself.
            writer.WriteStartElement(chunk.Name);

            // Write out any values.
            foreach (string key in chunk.Values.Keys)
            {
                writer.WriteStartElement("Value");
                writer.WriteAttributeString("Name", key);
                writer.WriteString(chunk.Values[key]);
                writer.WriteEndElement();
            }

            // Recurse children.
            foreach (Chunk c in chunk)
            {
                WriteStep(writer, c);
            }

            writer.WriteEndElement();
        }
Example #59
0
 public void Save(System.Xml.XmlTextWriter x)
 {
     x.WriteWhitespace("\t");
     x.WriteStartElement("Group");
     x.WriteAttributeString("name", Name);
     x.WriteWhitespace("\r\n");
     foreach (Timer timer in Timers)
     {
         x.WriteWhitespace("\t\t");
         x.WriteStartElement("timer");
         x.WriteAttributeString("name", timer.Name);
         x.WriteEndElement();
         x.WriteWhitespace("\r\n");
     }
     foreach (Rate rate in Rates)
     {
         x.WriteWhitespace("\t\t");
         x.WriteStartElement("rate");
         x.WriteAttributeString("value", rate.Value.ToString());
         x.WriteAttributeString("format", rate.Format);
         x.WriteEndElement();
         x.WriteWhitespace("\r\n");
     }
     foreach (Target target in Targets)
     {
         x.WriteWhitespace("\t\t");
         x.WriteStartElement("target");
         x.WriteAttributeString("value", target.Value.ToString());
         x.WriteAttributeString("period", target.Period);
         x.WriteAttributeString("exclude-weekends", target.ExcludeWeekend.ToString());
         x.WriteEndElement();
         x.WriteWhitespace("\r\n");
     }
     x.WriteWhitespace("\t");
     x.WriteEndElement();
     x.WriteWhitespace("\r\n");
 }
Example #60
0
        public static void SaveToXml(System.Xml.XmlTextWriter xmlWriter, IImageSet imageset, string alternateUrl)
        {
            xmlWriter.WriteStartElement("ImageSet");

            xmlWriter.WriteAttributeString("Generic", imageset.Generic.ToString());
            xmlWriter.WriteAttributeString("DataSetType", imageset.DataSetType.ToString());
            xmlWriter.WriteAttributeString("BandPass", imageset.BandPass.ToString());
            if (!imageset.Generic)
            {
                xmlWriter.WriteAttributeString("Name", imageset.Name);

                if (String.IsNullOrEmpty(alternateUrl))
                {
                    xmlWriter.WriteAttributeString("Url", imageset.Url);
                }
                else
                {
                    xmlWriter.WriteAttributeString("Url", alternateUrl);
                }
                xmlWriter.WriteAttributeString("DemUrl", imageset.DemUrl);
                xmlWriter.WriteAttributeString("BaseTileLevel", imageset.BaseLevel.ToString());
                xmlWriter.WriteAttributeString("TileLevels", imageset.Levels.ToString());
                xmlWriter.WriteAttributeString("BaseDegreesPerTile", imageset.BaseTileDegrees.ToString());
                xmlWriter.WriteAttributeString("FileType", imageset.Extension);
                xmlWriter.WriteAttributeString("BottomsUp", imageset.BottomsUp.ToString());
                xmlWriter.WriteAttributeString("Projection", imageset.Projection.ToString());
                xmlWriter.WriteAttributeString("QuadTreeMap", imageset.QuadTreeTileMap);
                xmlWriter.WriteAttributeString("CenterX", imageset.CenterX.ToString());
                xmlWriter.WriteAttributeString("CenterY", imageset.CenterY.ToString());
                xmlWriter.WriteAttributeString("OffsetX", imageset.OffsetX.ToString());
                xmlWriter.WriteAttributeString("OffsetY", imageset.OffsetY.ToString());
                xmlWriter.WriteAttributeString("Rotation", imageset.Rotation.ToString());
                xmlWriter.WriteAttributeString("Sparse", imageset.Sparse.ToString());
                xmlWriter.WriteAttributeString("ElevationModel", imageset.ElevationModel.ToString());
                xmlWriter.WriteAttributeString("StockSet", imageset.DefaultSet.ToString());
                xmlWriter.WriteAttributeString("WidthFactor", imageset.WidthFactor.ToString());
                xmlWriter.WriteAttributeString("MeanRadius", imageset.MeanRadius.ToString());
                xmlWriter.WriteAttributeString("ReferenceFrame", imageset.ReferenceFrame);
                if (String.IsNullOrEmpty(alternateUrl))
                {
                    xmlWriter.WriteElementString("ThumbnailUrl", imageset.ThumbnailUrl);
                }
                else
                {
                    xmlWriter.WriteElementString("ThumbnailUrl", imageset.Url);
                }
            }
            xmlWriter.WriteEndElement();
        }