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


C# XDocument.AddFirst方法代码示例

本文整理汇总了C#中System.Xml.Linq.XDocument.AddFirst方法的典型用法代码示例。如果您正苦于以下问题:C# XDocument.AddFirst方法的具体用法?C# XDocument.AddFirst怎么用?C# XDocument.AddFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.Linq.XDocument的用法示例。


在下文中一共展示了XDocument.AddFirst方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadingListToXml

 public static void ReadingListToXml(string fileName)
 {
     DataTable readData = DatabaseWrapper.GetCompleteReadingData();
     XDocument xDocument = new XDocument(
         new XDeclaration("1.0", "utf-8", "yes"),
         new XComment("Reading List Xml file"));
     XElement rootElement = new XElement("mangaReadingList");
     xDocument.AddFirst(rootElement);
     for (int i = 0; i < readData.Rows.Count; i++)
     {
         Debug.WriteLine(readData.Rows[i][1].ToString());
         XElement readElement = new XElement("manga",
                                             new XElement("Title",
                                                          DatabaseWrapper.GetMangaTitle(
                                                              int.Parse(readData.Rows[i][1].ToString()))),
                                             new XElement("startingChapter", readData.Rows[i][2].ToString()),
                                             new XElement("currentChapter", readData.Rows[i][3].ToString()),
                                             new XElement("onlineURL", readData.Rows[i][4].ToString()),
                                             new XElement("finishedReading",
                                                          bool.Parse(readData.Rows[i][5].ToString())),
                                             new XElement("dateRead", readData.Rows[i][6].ToString()),
                                             new XElement("mangaNote", readData.Rows[i][7].ToString())
             );
         rootElement.Add(readElement);
     }
     xDocument.Save(fileName);
 }
开发者ID:kelsos,项目名称:mra-net-sharp,代码行数:27,代码来源:IoWrapper.cs

示例2: XMLExcel

 /// <summary>
 /// Создание объекта формирования xml файла
 /// </summary>
 /// <param name="workSheetName">Имя листа</param>
 public XMLExcel( string workSheetName )
 {
     _data = new XDocument( new XDeclaration( "1.0", "", "" ) );
     _data.AddAnnotation( "mso-application progid=\"Excel.Sheet\"" );
     _rootEX = new XElement( _ss + "Workbook",
         new XAttribute( "xmlns", _ss.NamespaceName ),
         new XAttribute( XNamespace.Xmlns + "o", _o.NamespaceName ),
         new XAttribute( XNamespace.Xmlns + "x", _x.NamespaceName ),
         new XAttribute( XNamespace.Xmlns + "ss", _ss.NamespaceName ),
         new XAttribute( XNamespace.Xmlns + "html", _html.NamespaceName ),
         new XElement( _o + "DocumentProperties",
             new XAttribute( "xmlns", _o.NamespaceName ),
             new XElement( _o + "Author", " " ),
             new XElement( _o + "Version", "12.00" ) ),
         new XElement( _x + "ExcelWorkbook",
             new XAttribute( "xmlns", _x.NamespaceName ),
             new XElement( _x + "ProtectStructure", "False" ),
             new XElement( _x + "ProtectWindows", "False" ) ),
         XElement.Parse( Resources.XMLExcelStyle ).FirstNode,
         new XElement( _ss + "Worksheet", new XAttribute( _ss + "Name", workSheetName ),
         _workTable = new XElement( _ss + "Table",
             new XAttribute( _x + "FullColumns", "1" ),
             new XAttribute( _x + "FullRows", "1" ),
             new XAttribute( _ss + "DefaultRowHeight", "15" ) ) ) );
     _data.AddFirst( _rootEX );
 }
开发者ID:dmziryanov,项目名称:ApecAuto,代码行数:30,代码来源:XMLExcel.cs

示例3: ToString

        public override string ToString()
        {
            var xml = new XDocument();
            var methodCall = new XElement("methodCall");
            methodCall.Add(new XElement("methodName", Method));
            xml.AddFirst(methodCall);

            if (Parameters.Count > 0)
            {
                var structi = new XElement("struct");
                var paramss = new XElement("params",
                                           new XElement("param",
                                                        new XElement("value", structi)));

                foreach (var xmlParameter in Parameters)
                {
                    var member = new XElement("member", new XElement("name", xmlParameter.Name), GetParameterValue(xmlParameter.Value));
                    structi.Add(member);
                }

                methodCall.Add(paramss);
            }

            return xml.ToString();
        }
开发者ID:space035,项目名称:gollum,代码行数:25,代码来源:XmlRequest.cs

示例4: ToXml

 /// <summary>
 /// Creates the XML contents of an eagle board file
 /// </summary>
 /// <returns></returns>
 public XDocument ToXml()
 {
     var doc= new XDocument()
     {
         Declaration = new       XDeclaration("1.0","utf-8",null)
     };
     var rootNode = new XElement("eagle",
         new XAttribute("version", this.Version),
         new XElement("drawing",
             GetLayers(),
             new XElement("board",
                 GetDimension(),
                 new XElement("libraries",
                     new XElement("library", new XAttribute("name", "default"),
                         GetPackages()
                         )
                     ),
                 new DefaultDesignRules().RulesXml,
                 GetElements(),
                 GetSignals())));
     doc.AddFirst(new XDocumentType("eagle", null, "eagle.dtd", null));
     doc.Add(rootNode);
     var x = new XElement("test");
     return doc;
 }
开发者ID:byuhci,项目名称:Digital_Glass,代码行数:29,代码来源:EagleBoard.Xml.cs

示例5: SaveTimetables

        /// <summary>
        /// Create html file with information about timetable and save it
        /// </summary>
        /// <param name="Path">Where html file should be saved</param>
        /// <param name="station">Station</param>
        public void SaveTimetables(string Path, Station station)
        {
            FileStream fs = new FileStream(Path, FileMode.Create);

            XDocument document = new XDocument();
            document.AddFirst(new XElement("html"));

            document.Root.Add(new XElement("head",
                new XElement("title", station.Name)));

            XElement body = new XElement("body");
            XElement div = new XElement("div");
            foreach (Timetable tt in station)
            {
                XElement inner = new XElement("div", new XAttribute("style", "width:800px;"));
                inner.Add(new XElement("div", tt.FirstStation + " - " + tt.LastStation, new XAttribute("style", "border:solid; float:left; width:400px; heigth:20px;"), new XAttribute("align", "center")),
                    new XElement("div", tt.TimeOfArrival.ToString() + " - " + tt.TimeOfDeparture.ToString(), new XAttribute("style", "border:solid; float:left; width:150px; heigth:20px;"), new XAttribute("align", "center")),
                    new XElement("div", tt.FreqType, new XAttribute("style", "border:solid; float:left; width:150px; heigth:20px;"), new XAttribute("align", "center")),
                    new XElement("br"));
                div.Add(inner);
            }
            body.Add(div);
            document.Root.Add(body);

            document.Save(fs);
            fs.Close();
        }
开发者ID:alexssource,项目名称:Labs,代码行数:32,代码来源:LINQHTML.cs

示例6: UserDal

 static UserDal()
 {
     if (File.Exists(UserDal.fileName) == false)
     {
         XDocument doc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
         doc.AddFirst(new XElement("users"));
         doc.Save(UserDal.fileName);
     }
 }
开发者ID:Ozerich,项目名称:labs,代码行数:9,代码来源:UserDAL.cs

示例7: CreateHtmlFromVideoCollection

        public void CreateHtmlFromVideoCollection(IEnumerable<Video> videos)
        {
            var document = new XDocument();
            document.AddFirst(new XDocumentType("html", null, null, null));

            var html = new XElement("html");
            var head = new XElement("head");
            var meta = new XElement("meta");

            meta.SetAttributeValue("charset", "UTF - 8");
            head.Add(meta);

            var title = new XElement("title", "Telerik Academy Video Archive");
            head.Add(title);

            var styles = new XElement("link");
            styles.SetAttributeValue("rel", "stylesheet");
            styles.SetAttributeValue("href", "styles/video-archive-styles.css");
            head.Add(styles);

            html.Add(head);

            var body = new XElement("body");
            var pageTitle = new XElement("h1", "Telerik Academy Videos");
            body.Add(pageTitle);

            foreach (var video in videos)
            {
                var div = new XElement("div", new XElement("h3", video.Title));
                div.SetAttributeValue("class", "container");

                var videoFrame = new XElement("iframe", string.Empty);
                videoFrame.SetAttributeValue("frameborder", "0");
                videoFrame.SetAttributeValue("src", "https://www.youtube.com/embed/" + video.VideoId);
                div.Add(videoFrame);

                var youtubeLink = new XElement("a", "Youtube");
                youtubeLink.SetAttributeValue("href", video.Link);

                div.Add(youtubeLink);
                body.Add(div);
            }

            html.Add(body);
            document.Add(html);
            var writerSettings = new XmlWriterSettings();
            writerSettings.OmitXmlDeclaration = true;
            writerSettings.NewLineOnAttributes = true;
            writerSettings.Indent = true;

            var writer = XmlWriter.Create("../../index.html", writerSettings);
            document.Save(writer);
            writer.Close();

            Console.WriteLine("index.html generated");
        }
开发者ID:Vyara,项目名称:Telerik-Academy,代码行数:56,代码来源:ProcessingHelper.cs

示例8: GenerateHtml

        private static void GenerateHtml(IEnumerable<Video> videos)
        {
            var doc = new XDocument();
            doc.AddFirst(new XDocumentType("html", null, null, null));

            var html = new XElement("html");
            var head = new XElement("head");

            var meta = new XElement("meta");
            meta.SetAttributeValue("charset", "UTF - 8");
            head.Add(meta);

            var title = new XElement("title", "Teleik Academy Videos");
            head.Add(title);

            var styles = new XElement("link");
            styles.SetAttributeValue("rel", "stylesheet");
            styles.SetAttributeValue("href", "stylesheet.css");
            head.Add(styles);

            html.Add(head);

            var body = new XElement("body");

            foreach (var video in videos)
            {
                var videoDiv = new XElement("div", new XElement("p", video.Title));
                videoDiv.SetAttributeValue("class", "container");

                var iframe = new XElement("iframe", string.Empty);
                iframe.SetAttributeValue("frameborder", "0");
                iframe.SetAttributeValue("src", @"https://www.youtube.com/embed/" + video.Id);
                videoDiv.Add(iframe);

                var link = new XElement("a", "Watch in YouTube");
                link.SetAttributeValue("href", video.Link);

                videoDiv.Add(link);
                body.Add(videoDiv);
            }

            html.Add(body);
            doc.Add(html);
            var settings = new XmlWriterSettings();
            settings.OmitXmlDeclaration = true;
            settings.NewLineOnAttributes = true;
            settings.Indent = true;

            var writter = XmlWriter.Create("../../index.html", settings);
            doc.Save(writter);
            writter.Close();

            //Console.WriteLine("You can find the generated index.html in the main directory");
        }
开发者ID:nikistefanov,项目名称:Telerik-Academy-Homework,代码行数:54,代码来源:EntryPoint.cs

示例9: SaveComputer

 public void SaveComputer(string Path, PC computer)
 {
     XDocument doc = new XDocument();
     XElement root = new XElement("Computer");
     root.Add(new XElement("ID", computer.ID));
     root.Add(new XElement("VideoCount", computer.VideoCount));
     root.Add(new XElement("RAMCount", computer.RAMCount));
     root.Add(new XElement("HDDCapacity", computer.HDDCapacity));
     doc.AddFirst(root);
     doc.Save(Path);
 }
开发者ID:alexssource,项目名称:Labs,代码行数:11,代码来源:XmlFile.cs

示例10: ConvertToCobertura

        public static XDocument ConvertToCobertura(XDocument openCoverReport, string sourcesDirectory)
        {
            if (openCoverReport == null)
            {
                throw new ArgumentNullException("openCoverReport");
            }

            XDocument result = new XDocument(new XDeclaration("1.0", null, null), CreateRootElement(openCoverReport, sourcesDirectory));
            result.AddFirst(new XDocumentType("coverage", null, "http://cobertura.sourceforge.net/xml/coverage-04.dtd", null));

            return result;
        }
开发者ID:skolima,项目名称:OpenCoverToCoberturaConverter,代码行数:12,代码来源:Converter.cs

示例11: SaveChannels

 public static void SaveChannels(IEnumerable<RSSChannel> channels,string fileName)
 {
     var document = new XDocument();;
     document.AddFirst(new XElement("channels"));
     foreach (var channel in channels)
     {
         var title = new XElement("title", channel.Title);
         var link = new XElement("link", channel.Link);
         document.Root.Add(new XElement("channel", title, link));
     }
     document.Save(fileName, SaveOptions.None);
 }
开发者ID:Zaid-Ajaj,项目名称:RSSReader,代码行数:12,代码来源:RSSDataManeger.cs

示例12: ViolationList

        public ViolationList()
        {
            _document = new XDocument();

            var header = new XElement("Modules");
            _document.AddFirst(header);

            var module = new XElement("Module");
            module.SetAttributeValue(XName.Get("Name"), "FluentValidation.Mvc3");

            _document.Descendants().First().Add(module);
        }
开发者ID:pauloortins,项目名称:CodeBlamer,代码行数:12,代码来源:ViolationList.cs

示例13: CreateReport

        public XDocument CreateReport(TestItem testItem, TestEnvironmentInfo testEnvironmentInfo)
        {
            XDocument report = new XDocument();
            report.AddFirst(new XDocumentType("html", null, null, null));

            var html = new XElement("html");
            html.Add(GetHead());
            html.Add(GetBody(testItem, testEnvironmentInfo));

            report.Add(html);

            return report;
        }
开发者ID:IIITanbI,项目名称:2,代码行数:13,代码来源:ReportGenerator.cs

示例14: ToPapXml

        public string ToPapXml()
        {
            var doc = new XDocument ();

            var docType = new XDocumentType("pap", "-//WAPFORUM//DTD PAP 2.1//EN", "http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd", "<?wap-pap-ver supported-versions=\"2.0\"?>");

            doc.AddFirst (docType);

            var pap = new XElement ("pap");

            var pushMsg = new XElement ("push-message");

            pushMsg.Add (new XAttribute ("push-id", this.PushId));
            pushMsg.Add(new XAttribute("source-reference", this.SourceReference));

            if (!string.IsNullOrEmpty (this.PpgNotifyRequestedTo))
                pushMsg.Add(new XAttribute("ppg-notify-requested-to", this.PpgNotifyRequestedTo));

            if (this.DeliverAfterTimestamp.HasValue)
                pushMsg.Add (new XAttribute ("deliver-after-timestamp", this.DeliverAfterTimestamp.Value.ToUniversalTime ().ToString("s", CultureInfo.InvariantCulture) + "Z"));
            if (this.DeliverBeforeTimestamp.HasValue)
                pushMsg.Add (new XAttribute ("deliver-before-timestamp", this.DeliverBeforeTimestamp.Value.ToUniversalTime ().ToString("s", CultureInfo.InvariantCulture) + "Z"));

            //Add all the recipients
            foreach (var r in Recipients)
            {
                var address = new XElement("address");

                var addrValue = r.Recipient;

                if (!string.IsNullOrEmpty(r.RecipientType))
                {
                    addrValue = string.Format("WAPPUSH={0}%3A{1}/TYPE={2}", System.Web.HttpUtility.UrlEncode(r.Recipient),
                        r.Port, r.RecipientType);
                }

                address.Add(new XAttribute("address-value", addrValue));
                pushMsg.Add (address);
            }

            pushMsg.Add (new XElement ("quality-of-service", new XAttribute ("delivery-method", this.QualityOfService.ToString ().ToLowerInvariant ())));

            pap.Add(pushMsg);
            doc.Add (pap);

            return "<?xml version=\"1.0\"?>" + Environment.NewLine + doc.ToString (SaveOptions.None);
        }
开发者ID:Donnie888,项目名称:LxServer,代码行数:47,代码来源:BlackberryNotification.cs

示例15: ConvertToCobertura

        public static XDocument ConvertToCobertura(XDocument openCoverReport, string sourcesDirectory, bool includeGettersSetters)
        {
            if (openCoverReport == null)
            {
                throw new ArgumentNullException(nameof(openCoverReport));
            }

            if (sourcesDirectory != null)
            {
                sourcesDirectory = sourcesDirectory.Replace("/", "\\");
            }

            XDocument result = new XDocument(new XDeclaration("1.0", null, null), CreateRootElement(openCoverReport, sourcesDirectory, includeGettersSetters));
            result.AddFirst(new XDocumentType("coverage", null, "http://cobertura.sourceforge.net/xml/coverage-04.dtd", null));

            return result;
        }
开发者ID:danielpalme,项目名称:OpenCoverToCoberturaConverter,代码行数:17,代码来源:Converter.cs


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