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


C# XmlDocument.ToString方法代码示例

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


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

示例1: DumpConfigs

        protected override void DumpConfigs()
        {
            try
            {
                var allTypes = DataTypeDefinition.GetAll();
                System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();

                var di = new DirectoryInfo(storageFolder);
                di.GetFiles().ToList().ForEach(x =>
                {
                    File.Delete(x.FullName);
                });

                foreach (var dt in allTypes)
                {
                    var doc = new XmlDocument();
                    doc.LoadXml(dt.ToXml(xmlDoc).OuterXml);
                    var xml = doc.ToString(4);

                    var fileName = dt.Text.ToAlias() + ".config";
                    var file = Path.Combine(storageFolder, fileName);
                    using (var fs = File.CreateText(file))
                    {
                        fs.Write(xml);
                    }
                }
            }
            catch { }
        }
开发者ID:tocsoft,项目名称:Umbraco-DeveloperFriendly,代码行数:29,代码来源:DataTypeSyncer.cs

示例2: GameTest

        public static void GameTest()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load("../../../Schema/DoorDemo.xml");
            Console.Write(doc.ToString());

            XmlReader r = XmlReader.Create("../../../Schema/DoorDemo.xml");
            string xmlcontents = doc.InnerXml;

            Console.Write(xmlcontents);
            Console.ReadLine();
        }
开发者ID:clintonm9,项目名称:NBALifeTest,代码行数:12,代码来源:Game.cs

示例3: Nota

        public Nota(String arquivoNotaXml)
        {
            if (!File.Exists(arquivoNotaXml))
            {
                throw new Exception("O arquivo de nota para envio não existe: " + arquivoNotaXml);
            }

            var xmlDoc = new XmlDocument();
            xmlDoc.Load(arquivoNotaXml);

            CaminhoFisico = arquivoNotaXml;
            ConteudoXml = xmlDoc.ToString();
        }
开发者ID:njmube,项目名称:NFeEletronica.NET,代码行数:13,代码来源:NotaFiscal.cs

示例4: getXML

 public static XmlDocument getXML(string fileName)
 {
     XmlDocument xml;
     if (map[fileName] is XmlDocument)
     {
         return map[fileName] as XmlDocument;
     } else {
         ByteArray byteArr = map[fileName] as ByteArray;
         xml = new XmlDocument();
         xml.Load(byteArr.MemoryStream);
         map[fileName] = xml;
         Debug.Log(xml.ToString());
     }
     return map[fileName] as XmlDocument;
 }
开发者ID:ucjedpfmd,项目名称:U3DGame,代码行数:15,代码来源:CommonLocator.cs

示例5: updateDatabase

        public void updateDatabase()
        {
            String method = "GET";
            String url = "https://www.mkmapi.eu/ws/v1.1/expansion/1/";
            HttpWebRequest request = WebRequest.CreateHttp(url) as HttpWebRequest;
            OAuthHeader header = new OAuthHeader();
            request.Headers.Add(HttpRequestHeader.Authorization, header.getAuthorizationHeader(method, url));
            request.Method = method;

            HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            XmlDocument doc = new XmlDocument();
            doc.Load(response.GetResponseStream());

            // Tratamos la lista de expansiones
            Console.WriteLine(doc.ToString());
        }
开发者ID:Neorbarus,项目名称:MKMCrawler,代码行数:16,代码来源:RequestHelper.cs

示例6: LoadTemplateURL

        public void LoadTemplateURL(string templates_navi_url)
        {
            XmlDocument xml = new XmlDocument();
            xml.Load(System.AppDomain.CurrentDomain.BaseDirectory + templates_navi_url);

            string x = xml.ToString();

            XmlNodeList nList = xml.SelectNodes("//Docments/Document");

            foreach (XmlNode node in nList)
            {
                TemplateRule rule = new TemplateRule();
                rule.ID = node.Attributes["id"].InnerXml;
                rule.TemplateURL = node.Attributes["Template"].InnerXml;
                rule.TargetURL = node.Attributes["TargetURL"].InnerXml;

                tempRules.Add(rule);
            }
        }
开发者ID:Dhenskr,项目名称:hoyi-er-tool,代码行数:19,代码来源:TemplateURLControl.cs

示例7: TestWithDocPath

		public void TestWithDocPath()
		{
			var parameters = new CompilerParameters();
			CommandLineParser.ParseInto(parameters,
				new string[] { "/doc:TestDoc.xml", "/target:library", "/o:TestDoc.dll", "TestDoc.boo" });
			var compiler = new BooCompiler(parameters);
			var context=compiler.Run();
			if (context.Errors.Count > 0)
			{
				Console.WriteLine(context.Errors);
				throw new AssertionException(context.Errors[0].ToString());
			}
			
			var reference = new XmlDocument();
			reference.Load("TestDocReference.xml");
			var result = new XmlDocument();
			result.Load("TestDoc.xml");
			
			Assert.AreEqual(reference.ToString(), result.ToString());
		}
开发者ID:hlizard,项目名称:boo,代码行数:20,代码来源:DocOptionTest.cs

示例8: GetDownloadableRecordings

        public List<Recording> GetDownloadableRecordings()
        {
            var retval = new List<Recording>();
            var urlRecordings = String.Format(UrlRecordings, Umgebung.Web.User, Umgebung.Web.Password);

            var docRecordings = new XmlDocument();
            docRecordings.Load(urlRecordings);

            Umgebung.Log.Dump("Bong recordings.xml Ergebnisdokument:\n{0}", docRecordings.ToString());

            var root = docRecordings.DocumentElement;
            if (root != null)
            {
                var nodes = root.SelectNodes("/recordings/recording");

                if (nodes != null)
                    foreach (XmlNode node in nodes)
                    {
                        var docRecording = new XmlDocument();

                        try
                        {
                            docRecording.InnerXml = node.OuterXml;
                            var xmlDecl = docRecording.CreateXmlDeclaration("1.0", "UTF-8", null);
                            var rootRecording = docRecording.DocumentElement;
                            docRecording.InsertBefore(xmlDecl, rootRecording);

                            Umgebung.Log.Dump("Neues XML-Dokument erstellt:\n{0}", docRecording.ToString());

                            var rec = new Recording()
                                          {
                                              // Id wird erst später nachgetragen
                                              BongId = GetNodeText(docRecording, "/recording/id"),
                                              Title = GetNodeText(docRecording, "/recording/title"),
                                              Subtitle = GetNodeText(docRecording, "/recording/subtitle"),
                                              Description = GetNodeText(docRecording, "/recording/description"),
                                              Channel = GetNodeText(docRecording, "/recording/channel"),
                                              Start = DateTime.Parse(GetNodeText(docRecording, "/recording/start"), new CultureInfo("de-DE"), DateTimeStyles.None),
                                              Duration = TimeSpan.Parse(GetNodeText(docRecording, "/recording/duration"), new CultureInfo("de-DE")),
                                              Genre = GetNodeText(docRecording, "/recording/genre"),
                                              SeriesSeason = GetNodeText(docRecording, "/recording/series_season"),
                                              SeriesNumber = GetNodeText(docRecording, "/recording/series_number"),
                                              SeriesCount = GetNodeText(docRecording, "/recording/series_count"),
                                              ImageUrl = GetNodeText(docRecording, "/recording/image"),
                                              DownloadUrlHD = GetNodeText(docRecording, "/recording/files/file[type='download' and quality='HD']/url"),
                                              DownloadUrlHQ = GetNodeText(docRecording, "/recording/files/file[type='download' and quality='HQ']/url"),
                                              DownloadUrlNQ = GetNodeText(docRecording, "/recording/files/file[type='download' and quality='NQ']/url")
                                          };

                            rec.Dump("Recording-Instanz aus Bong-XML erstellt");

                            retval.Add(rec);
                        }
                        catch (Exception ex)
                        {
                            Umgebung.Log.Error("Initialisieren von Recording aus der XML-Struktur schlug fehl: {0}\n{1}", ex.Message, docRecording.ToString());
                        }
                    }
            }

            return retval;
        }
开发者ID:jostebo,项目名称:Mojimo,代码行数:62,代码来源:RecordingService.cs

示例9: TransformIncludes

        public static XmlDocument TransformIncludes(this XmlDocument dom)
        {
            foreach (XmlNode item in dom.DocumentElement.SelectNodes("include"))
            {
                var d = new XmlDocument();
                d.Load(item.Attributes?["src"]?.Value);

                switch (item.Attributes?["type"]?.Value)
                {
                    case "text/xml":
                        var n = dom.ImportNode(d.DocumentElement, true);

                        dom.DocumentElement.ReplaceChild(n, item);

                        break;
                    case "text/component+xml":
                        dom.CreateComponent(d.ToString());

                        dom.DocumentElement.RemoveChild(item);

                        break;
                    default:
                        dom.CreateComponent(d.ToString());

                        dom.DocumentElement.RemoveChild(item);

                        break;
                }
            }

            return dom;
        }
开发者ID:SchwarzerLoewe,项目名称:XmlComponent,代码行数:32,代码来源:Extensions.cs

示例10: LoadFile

        public static XmlDocument LoadFile(string path)
        {
            FileStream fs = null;
            try
            {
                FileInfo info = new FileInfo(path);
                if (!info.Exists)
                {
                    return null;
                }
                fs = info.Open(FileMode.Open);
                XmlDocument xml = new XmlDocument();
                xml.Load(fs);
                return xml;
            }
            catch (XmlException xml)
            {
                Console.WriteLine(xml.ToString());
                return null;
            }
            finally
            {
                if (fs != null)
                {
                    try { fs.Close(); }
                    catch (Exception) { }
                }
            }

        }
开发者ID:sr3dna,项目名称:big5sync,代码行数:30,代码来源:ProfilingXMLHelper.cs

示例11: TCM_UpdateTabResultsManager

        public void TCM_UpdateTabResultsManager()
        {
            this.tabControl1.Controls.Add(this.AddIssue);
            this.TabResultsManager.Controls.Add(this.PanelResultsManagerTiltle);
            this.TabResultsManager.Controls.Add(this.TabControlIssues);
            this.PictureBoxMaximizeResultTab.Visible = false ;
            this.PictureBoxMinResultsTab.Visible = true;
            this.TabControlIssues.Visible = true ;

            if (_TCM_CountForControlsChange == 0)
            {
                _TCM_UpdateCount++;
                FileInfo file = new FileInfo(projectApp.ProjectFileName);
                string projectStructureFile = Path.Combine(file.DirectoryName, Path.GetFileNameWithoutExtension(projectApp.ProjectFileName) + ".xml");
                //string projectStructureFile = Path.GetFileNameWithoutExtension(projectApp.ProjectFileName) + ".xml";
                string finalHtmlFile = projectStructureFile.ToLower().Replace(".xml", ".html");
                try
                {
                    ProjectXmlFile(projectStructureFile);
                    string tempFile1 = Path.GetFileNameWithoutExtension(projectApp.ProjectFileName) + "1.xml";
                    string tempFile2 = Path.GetFileNameWithoutExtension(projectApp.ProjectFileName) + "2.xml";
                    string tempFile3 = Path.GetFileNameWithoutExtension(projectApp.ProjectFileName) + "3.xml";
                    if (!_MainForm.ToolBarFilterResults.Pushed)
                    {
                        if(projectApp.Sessions.Count != 0)
                        {
                            Convert(Path.GetFileName(projectStructureFile), tempFile1, "createsum.xsl");
                            Convert(tempFile1,tempFile2,"sortontype.xsl");
                            Convert(tempFile2,tempFile3, "sortonmes.xsl");
                            Convert(tempFile3,  finalHtmlFile, "viewonmes.xsl");
                        }
                    }
                    else
                    {
                        FileInfo fileInfo = new FileInfo(resultProjectXml);
                        if (fileInfo.Exists)
                        {
                            XmlDocument xmldoc= null;
                            try
                            {
                                xmldoc = new XmlDocument();
                                xmldoc.Load(fileInfo.FullName);
                            }
                            catch(Exception e)
                            {
                                MessageBox.Show(e.Message+ "-----"+ xmldoc.ToString());
                                CreateXmlTemplate();
                            }
                        }
                        if ( !fileInfo.Exists)
                        {
                            CreateXmlTemplate();
                        }
                        ProjectXmlFile(projectStructureFile);
                        if(projectApp.Sessions.Count != 0)
                        {
                            Convert(Path.GetFileName(projectStructureFile), tempFile1, "createsum.xsl");
                            Convert(tempFile1,tempFile2,"sortontype.xsl");
                            Convert(tempFile2,tempFile3, "sortonmes.xsl");
                            Convert(tempFile3,  finalHtmlFile, "viewonmesfiltered.xsl");
                        }
                    }
                    webBrowserResultMgr.Navigate(finalHtmlFile);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }

                _TCM_UpdateCount--;
            }
        }
开发者ID:ewcasas,项目名称:DVTK,代码行数:72,代码来源:ProjectForm2.cs

示例12: WhenGetXmlIsCalled_ResponseContentIsDeserialized

        public async Task WhenGetXmlIsCalled_ResponseContentIsDeserialized()
        {
            var expectedString = "<root><foo>Foo</foo><bar>Bar</bar></root>";
            var expected = new XmlDocument();
            expected.LoadXml(expectedString);

            var stubHandler = new FakeHttpMessageHandler(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(expectedString)
            });
            var http = new HttpWrapper("http://foo.com/",
                new TestLogger(),
                new Envelope(new TextMessage(CreateTestUser(), "test", "id")),
                stubHandler);

            var actual = await http.GetXml();

            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
开发者ID:nardin,项目名称:mmbot,代码行数:19,代码来源:HttpWrapperTests.cs

示例13: SaveData

        public long SaveData(
            XmlDocument xmlDoc)
        {
            SqlConnection conn = null;
            SqlCommand cmd = null;
            StringBuilder sql = new StringBuilder();
            StringBuilder fields = new StringBuilder();
            StringBuilder values = new StringBuilder();
            string cmdName = null;
            long retVal = 0;

            try {
                conn = GetConnection();
                conn.Open();

                XmlNode cmdNode = xmlDoc.DocumentElement;

                        // Set table name
                tableName = cmdNode.Attributes["table"].Value;
                aliases.Add(tableName, string.Format("{0}", "0"));
                cmdName = cmdNode.Name.ToLower();

                        // If this is an insert request ...
                if (cmdName == "insert") {
                    cmd = new SqlCommand();
                    cmd.Connection = conn;

                    XmlNodeList rowNodes = cmdNode.SelectNodes("Row");

                            // If set indentity is true, turn on the set indentity_insert
                    if (SetIdentity) {
                        sql.Append(string.Format("if IDENT_CURRENT('{0}') IS NOT NULL\nBEGIN\nset identity_insert {0} on;", tableName));
                    }

                            // For each row ...
                    foreach (XmlNode row in rowNodes) {
                        sql.Append(string.Format("insert into {0} ", tableName));
                        fields.Append("(");
                        values.Append("values (");

            //					XmlNode fieldsNode = row.SelectSingleNode("//Fields");
                        Set fieldSet = GetFields(row.SelectSingleNode("//Fields"), cmd);

                                // For each field returned: append field name and value
                        foreach (string field in fieldSet) {
                            fields.Append(string.Format("{0}, ", field));
                            values.Append(string.Format("@{0}, ", field));
            //						cmd.Parameters["@" + field].Value =
            //  !! need to add the param here
                        }

                                // Remove the extra comma and space
                        fields.Remove(fields.Length - 2, 2);
                        fields.Append(") ");
                        values.Remove(values.Length - 2, 2);
                        values.Append(") ");

                                // Append the fields and values clauses
                        sql.Append(fields + values.ToString() + ";select IDENT_CURRENT('" + tableName + "')");

                                // Turn off the set indentity_insert
                        if (SetIdentity) {
                            sql.Append(string.Format("set identity_insert {0} off\nEND ", tableName));
                        }

                                // Set commandtext and execute command
                        cmd.CommandText = sql.ToString();
                        object ident = cmd.ExecuteScalar();

                                //  if there is an identity field the identity of the new record should be returned,
                                //  but if there is no identity field we need to return something other than 0 which
                                //  indicates an error occurred
                        if (ident is Decimal) {
                            retVal = (long)((Decimal)ident);
                        } else {
                            retVal = -1;
                        }
                    }
                } else if (cmdName == "update") {
                    StringBuilder update = new StringBuilder();
                    StringBuilder where = new StringBuilder();
                    Set fieldSet = null;

                    cmd = new SqlCommand();
                    cmd.Connection = conn;
                    fieldSet = GetFields(cmdNode.SelectSingleNode("Fields"), cmd);
                    update.Append("SET ");

                            // For each field returned: append field name and value
                    foreach (string field in fieldSet) {
                        update.Append(string.Format("{0} = @{0}, ", field));
                    }

                            // Remove the extra comma
                    update.Remove(update.Length - 2, 2);

                            // Add where conditions
                    if (cmdNode.SelectSingleNode("Where").ChildNodes.Count > 0) {
                        where.Append(" WHERE ");
                        where.Append(BuildConditions(cmdNode.SelectSingleNode("Where"), cmd, null));
//.........这里部分代码省略.........
开发者ID:rogue-bit,项目名称:Triton-Framework,代码行数:101,代码来源:MsGenericDao.cs

示例14: btnSearch_Click

        private void btnSearch_Click(object sender, EventArgs e)
        {
            // setup variables for response time
            DateTime responseReceived = new DateTime();
            DateTime requestStarted = new DateTime();

            try
            {
                Cursor = Cursors.WaitCursor;
                ClearResponseTree();

                // get the request url and request method
                string graphRequest = tbRequestUrl.Text;
                HttpMethod HttpRequestMethod;

                switch (cmbHttpMethod.Text)
                {
                    case "GET":
                        HttpRequestMethod = HttpMethod.Get;
                        break;
                    case "POST":
                        HttpRequestMethod = HttpMethod.Post;
                        break;
                    case "PUT":
                        HttpRequestMethod = HttpMethod.Put;
                        break;
                    case "HEAD":
                        HttpRequestMethod = HttpMethod.Head;
                        break;
                    case "OPTIONS":
                        HttpRequestMethod = HttpMethod.Options;
                        break;
                    default:
                        HttpRequestMethod = HttpMethod.Delete;
                        break;
                }

                // create the http request and add the access token in the header
                HttpRequestMessage request = new HttpRequestMessage(HttpRequestMethod, graphRequest);
                request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken);

                // check for diagnostics flag
                if (Properties.Settings.Default.OutlookDiagnostics == "On")
                {
                    AddRequestHeader("Prefer", "outlook.diagnostics");
                }

                // add headers to the request
                foreach (DataGridViewRow row in dgRequestHeaders.Rows)
                {
                    request.Headers.Add(row.Cells[0].Value.ToString(), row.Cells[1].Value.ToString());
                }

                // check for a request body
                if (tbRequestBody.Text != "")
                {
                    request.Content = new StringContent(tbRequestBody.Text, System.Text.Encoding.UTF8, "application/json");
                }

                logger.Log("REQUEST HEADER:");
                logger.Log(request.Headers.ToString());
                logger.Log("REQUEST:");
                logger.Log(request.ToString());

                // get the current time for response time calculation
                requestStarted = DateTime.Now;

                // start processing the response
                HttpResponseMessage response = httpClient.SendAsync(request).Result;

                // get the current time again to figure out the response time
                responseReceived = DateTime.Now;

                // calculate the number of milliseconds that the request took to complete
                TimeSpan milliseconds = responseReceived.Subtract(requestStarted);
                logger.Log("RESPONSE TIME = " + milliseconds);

                // handle non-successful requests
                if (!response.IsSuccessStatusCode)
                {
                    string errorJsonContent = response.Content.ReadAsStringAsync().Result;

                    JObject jResult = JObject.Parse(errorJsonContent);

                    // check for odata error
                    if (jResult["odata.error"] != null)
                    {
                        throw new Exception((string)jResult["odata.error"]["message"]["value"]);
                    }

                    // check for null result
                    if (jResult[""] != null)
                    {
                        logger.Log("## null response ##");
                    }

                    // log non-odata errors
                    logger.Log("RESPONSE JSON CONTENT:");
                    logger.Log(jResult.ToString());

//.........这里部分代码省略.........
开发者ID:desjarlais,项目名称:restfuloutlook,代码行数:101,代码来源:GraphAPI.cs


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