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


C# System.Xml.XmlDocument.Load方法代码示例

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


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

示例1: LoadData

 public void LoadData(bool show_error)
 {
     buttonAggiorna.Enabled = numStagione.Enabled = false;
     try
     {
         Internal.Main.StatusString = "Download dell'elenco delle partite in corso...";
         string stagione = numStagione.Value.ToString();
         string url = string.Format(@"http://www.rugbymania.net/export_xml_part.php?lang=italiano&season={2}&id={0}&access_key={1}&object=calendar",
             Properties.Settings.Default.RM_Id, Properties.Settings.Default.RM_Codice, stagione);
         System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
         try
         {
             doc.Load(url);
         }
         catch (Exception ex)
         {
             if (show_error) My.Box.Errore("Impossibile scaricare i dati delle partite\r\n"+ex.Message);
             if (System.IO.File.Exists(DEFAULT_DATA)) doc.Load(DEFAULT_DATA);
         }
         Internal.Main.StatusString = "Download dell'elenco delle partite terminato!";
         ShowPartite(doc);
         if (doc.HasChildNodes) doc.Save(DEFAULT_DATA);
     }
     catch (Exception ex)
     {
         #if(DEBUG)
         My.Box.Info("TabClassifica::LoadData\r\n" + ex.Message);
         #endif
         Internal.Main.Error_on_xml();
     }
     buttonAggiorna.Enabled = numStagione.Enabled = true;
 }
开发者ID:faze79,项目名称:rmo-rugbymania,代码行数:32,代码来源:TabPartite.cs

示例2: SetNode

        private static void SetNode(string cpath)
        {   
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(cpath);
            Console.WriteLine("Adding to machine.config path: {0}", cpath);

            foreach (DataProvider dp in dataproviders)
            {
                System.Xml.XmlNode node = doc.SelectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=\"" + dp.invariant + "\"]");
                if (node == null)
                {
                    System.Xml.XmlNode root = doc.SelectSingleNode("configuration/system.data/DbProviderFactories");
                    node = doc.CreateElement("add");
                    System.Xml.XmlAttribute at = doc.CreateAttribute("name");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("invariant");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("description");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("type");
                    node.Attributes.Append(at);
                    root.AppendChild(node);
                }
                node.Attributes["name"].Value = dp.name;
                node.Attributes["invariant"].Value = dp.invariant;
                node.Attributes["description"].Value = dp.description;
                node.Attributes["type"].Value = dp.type;
                Console.WriteLine("Added Data Provider node in machine.config.");
            }            

            doc.Save(cpath);
            Console.WriteLine("machine.config saved: {0}", cpath);
        }
开发者ID:erisonliang,项目名称:qizmt,代码行数:33,代码来源:Program.cs

示例3: Load

        public void Load()
        {
            var redirectRuleConfigFile = System.Configuration.ConfigurationManager.AppSettings["RedirectRuleConfigFile"];
            if (System.IO.File.Exists(redirectRuleConfigFile))
            {
                var xmd = new System.Xml.XmlDocument();
                xmd.Load(redirectRuleConfigFile);

                var nodes = xmd.GetElementsByTagName("RedirectRule");
                foreach (System.Xml.XmlElement xme in nodes)
                {
                    var callingClient = IPAddress.Any; //Not yet supported "CallingClient"
                    var requestHost = xme.Attributes["RequestHost"].Value;
                    var requestPort = int.Parse(xme.Attributes["RequestPort"].Value);
                    var targetAddress = xme.Attributes["TargetAddress"].Value;
                    var targetPort = int.Parse(xme.Attributes["TargetPort"].Value);

                    Instance.Add(new RedirectRule(callingClient, requestHost, requestPort, IPAddress.Parse(targetAddress), targetPort), false);
                }
            }

            //Append sample redirect rules
            //Instance.Add(new RedirectRule(IPAddress.Any, null, 3001, IPAddress.Parse("127.0.0.1"), 3002), false);
            //Instance.Add(new RedirectRule(IPAddress.Any, "ws1.test.com", 3003, IPAddress.Parse("127.0.0.1"), 3002), false);
            //Save();
        }
开发者ID:poxet,项目名称:Rubicon-Reverse-Proxy,代码行数:26,代码来源:RedirectRuleManager.cs

示例4: Init

        public void Init(HttpApplication context)
        {
            System.Xml.XmlDocument _document = new System.Xml.XmlDocument();
            _document.Load(Xy.Tools.IO.File.foundConfigurationFile("App", Xy.AppSetting.FILE_EXT));
            foreach (System.Xml.XmlNode _item in _document.GetElementsByTagName("Global")) {
                string _className = _item.InnerText;
                Type _tempCtonrlType = Type.GetType(_className, false, true);
                IGlobal _tempGlobal;
                if (_tempCtonrlType == null) {
                    System.Reflection.Assembly asm = System.Reflection.Assembly.Load(_className.Split(',')[0]);
                    _tempCtonrlType = asm.GetType(_className.Split(',')[1], false, true);
                }
                _tempGlobal = System.Activator.CreateInstance(_tempCtonrlType) as IGlobal;
                if (_tempGlobal != null) {
                    global = _tempGlobal;
                }
            }
            if (global == null) { global = new EmptyGlobal(); }
            global.ApplicationInit(context);

            context.BeginRequest += new EventHandler(context_BeginRequest);
            context.Error += new EventHandler(context_Error);
            context.EndRequest += new EventHandler(context_EndRequest);
            _urlManager = URLManage.URLManager.GetInstance();
        }
开发者ID:BrookHuang,项目名称:XYFrame,代码行数:25,代码来源:HttpModule.cs

示例5: Main

        static void Main()
        {
            var xmlSearch = new System.Xml.XmlDocument();

            //select one of the above Query, Query1
            xmlSearch.Load(Query1);
            
            var query = xmlSearch.SelectSingleNode("/query");
            
            var author = query[Author].GetText();
            var title = query[Title].GetText();
            var isbn = query[ISBN].GetText();
         
            var dbContext = new BookstoreDbContext();

            var queryLogEntry = new SearchLogEntry
            {
                Date = DateTime.Now,
                QueryXml = query.OuterXml
            };

            var foundBooks = GenerateQuery(author, title, isbn, dbContext);

            dbContext.SearchLog.Add(queryLogEntry);
            dbContext.SaveChanges();

            PrintResult(foundBooks);
        }
开发者ID:Jarolim,项目名称:AllMyHomeworkForTelerikAcademy,代码行数:28,代码来源:SimpleSearch.cs

示例6: menuitem_Click

		void menuitem_Click(object sender, EventArgs e)
		{

			System.Windows.Forms.OpenFileDialog of = new System.Windows.Forms.OpenFileDialog();
			of.DefaultExt = ".xml";
			of.Filter = "XMLファイル(*.xml)|*.xml";
			if (of.ShowDialog((System.Windows.Forms.IWin32Window)_host.Win32WindowOwner) == System.Windows.Forms.DialogResult.OK) {
				try {
					System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
					xdoc.Load(of.FileName);

					// 擬似的に放送に接続した状態にする
					_host.StartMockLive("lv0", System.IO.Path.GetFileNameWithoutExtension(of.FileName), DateTime.Now);
					
					// ファイル内のコメントをホストに登録する
					foreach (System.Xml.XmlNode node in xdoc.SelectNodes("packet/chat")) {
						Hal.OpenCommentViewer.Control.OcvChat chat = new Hal.OpenCommentViewer.Control.OcvChat(node);
						_host.InsertPluginChat(chat);
					}
					_host.ShowStatusMessage("インポートに成功しました。");

				}catch(Exception ex){
					NicoApiSharp.Logger.Default.LogException(ex);
					_host.ShowStatusMessage("インポートに失敗しました。");

				}
			}
			
		}
开发者ID:nico-lab,项目名称:niconama-ocv,代码行数:29,代码来源:Importer.cs

示例7: Main

        static void Main(string[] args)
        {
            string applicationDirectory = System.Reflection.Assembly.GetExecutingAssembly().Location;
            applicationDirectory = applicationDirectory.Substring(0, applicationDirectory.LastIndexOf(@"\")+1);
            using (StreamReader reader = File.OpenText( FilePath ) )
            {
                string line = null;
                do
                {
                    line = reader.ReadLine();
                    if (line != null)
                    {
                        string[] items = line.Split(',');
                        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                        string url = items[XmlColumn];
                        try
                        {
                            doc.Load(url);
                            string filename = items[XmlColumn].Substring(items[XmlColumn].LastIndexOf("/") + 1);
                            string filepath = Path.Combine(applicationDirectory, SaveFolder, filename);
                            doc.Save(filepath);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("Exception: " + url + "\r\n" + e.Message);
                        }

                    }
                }
                while( line != null );
            }
            Console.Write("Press Enter key to close. ");
            while( Console.ReadKey().Key != ConsoleKey.Enter );
        }
开发者ID:jdaley,项目名称:SydneyLexicographer,代码行数:34,代码来源:Program.cs

示例8: GetEntryNames

        /// <summary>
        ///   Retrieves the names of all the entries inside a section. </summary>
        /// <param name="section">
        ///   The name of the section holding the entries. </param>
        /// <returns>
        ///   If the section exists, the return value is an array with the names of its entries; 
        ///   otherwise it's null. </returns>
        /// <exception cref="InvalidOperationException">
        ///	  <see cref="Profile.Name" /> is null or empty. </exception>
        /// <exception cref="ArgumentNullException">
        ///   section is null. </exception>
        /// <exception cref="XmlException">
        ///	  Parse error in the XML being loaded from the file. </exception>
        /// <seealso cref="Profile.HasEntry" />
        /// <seealso cref="GetSectionNames" />
        public string[] GetEntryNames(string section)
        {
            // Verify the section exists
              if (!UserSectionExists(section))
            return null;

              VerifyAndAdjustSection(ref section);

              System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
              doc.Load(_filePath);

              if (doc == null)
            return null;

              // Get the root node, if it exists
              System.Xml.XmlElement root = doc.DocumentElement;
              if (root == null)
            return null;

              // Get the entry nodes
              System.Xml.XmlNodeList entryNodes = root.SelectNodes(GetSectionsPath(section) + "/entry[@name]");
              if (entryNodes == null)
            return null;

              // Add all entry names to the string array
              string[] entries = new string[entryNodes.Count];
              int i = 0;

              foreach (System.Xml.XmlNode node in entryNodes)
            entries[i++] = node.Attributes["name"].Value;

              //  Return the Array of Entry Names to the calling method.
              return entries;
        }
开发者ID:MitchVan,项目名称:DataMaintenanceUtilities,代码行数:49,代码来源:XMLSetttingsFileManager.cs

示例9: GetConfigurationFromEmbeddedFile

        public static EmbeddedConfiguration GetConfigurationFromEmbeddedFile(string logicalConnectionName)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            using (System.IO.Stream s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ITPCfSQL.Azure.CLR.Configuration.Connections.xml"))
            {
                doc.Load(s);
            }

            string query = "ConnectionList/Connection[LogicalName='" + logicalConnectionName + "']";

            //Microsoft.SqlServer.Server.SqlContext.Pipe.Send(query);

            System.Xml.XmlNode node = doc.SelectSingleNode(query);

            if (node == null)
                throw new ArgumentException("Cannot find \"" + logicalConnectionName + "\" logical connection. Are you sure you spelled it right?");

            try
            {
                return new EmbeddedConfiguration()
            {
                LogicalName = node.SelectSingleNode("LogicalName").InnerText,
                AccountName = node.SelectSingleNode("AccountName").InnerText,
                SharedKey = node.SelectSingleNode("SharedKey").InnerText,
                UseHTTPS = bool.Parse(node.SelectSingleNode("UseHTTPS").InnerText)
            };
            }
            catch (Exception exce)
            {
                throw new ArgumentException("There is an error in the configuration file. Some node is missing.", exce);
            }
        }
开发者ID:DomG4,项目名称:sqlservertoazure,代码行数:32,代码来源:EmbeddedConfiguration.cs

示例10: ListContainers

        public List<Container> ListContainers(
            string prefix = null,
            bool IncludeMetadata = false,
            int timeoutSeconds = 0,
            Guid? xmsclientrequestId = null)
        {
            List<Container> lContainers = new List<Container>();
            string strNextMarker = null;
            do
            {
                string sRet = Internal.InternalMethods.ListContainers(
                    AccountName, SharedKey, UseHTTPS,
                    prefix, strNextMarker,
                    IncludeMetadata: IncludeMetadata, timeoutSeconds: timeoutSeconds, xmsclientrequestId: xmsclientrequestId);

                //Microsoft.SqlServer.Server.SqlContext.Pipe.Send("After Internal.InternalMethods.ListQueues = " + sRet);

                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                using (System.IO.StringReader sr = new System.IO.StringReader(sRet))
                {
                    doc.Load(sr);
                }

                lContainers.AddRange(Container.ParseFromXMLEnumerationResults(this, doc));

                strNextMarker = Container.GetNextMarkerFromXMLEnumerationResults(doc);

            } while (!string.IsNullOrEmpty(strNextMarker));

            return lContainers;
        }
开发者ID:DomG4,项目名称:sqlservertoazure,代码行数:31,代码来源:AzureBlobService.cs

示例11: CreateGamesIni

        public static void CreateGamesIni(string inputXML,string gamesIniPath)
        {
            //string filename = args[0];
                //Console.WriteLine(filename);
                System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
                xdoc.Load(inputXML);

                var di = new DirectoryInfo(gamesIniPath);
                var fi = new FileInfo(gamesIniPath + "\\games.ini");
                di.Attributes &= FileAttributes.Normal;

                if (File.Exists(fi.FullName))
                    fi.Attributes &= ~FileAttributes.ReadOnly;

                using (System.IO.StreamWriter file = new System.IO.StreamWriter(gamesIniPath + "\\games.ini", true))
                {
                    file.WriteLine("# This file is only used for remapping specific games to other Emulators and/or Systems.");
                    file.WriteLine("# If you don't want your game to use the Default_Emulator, you would set the Emulator key here.");
                    file.WriteLine("# This file can also be used when you have Wheels with games from other Systems.");
                    file.WriteLine("# You would then use the System key to tell HyperLaunch what System to find the emulator settings.");
                    file.WriteLine("");

                }

                foreach (System.Xml.XmlNode node in xdoc.SelectNodes("menu/game"))
                {
                    string GameName = node.SelectSingleNode("@name").InnerText;
                    string sysName = node.SelectSingleNode("System").InnerText;
                    using (System.IO.StreamWriter file = new System.IO.StreamWriter(gamesIniPath + "\\games.ini", true))
                    {
                        file.WriteLine("[{0}]", GameName);
                        file.WriteLine(@"System={0}", sysName);
                    }
                }
        }
开发者ID:horseyhorsey,项目名称:HyperMint,代码行数:35,代码来源:RomMapper.cs

示例12: Init

        public static void Init()
        {
            Version = new CVar("smod_version", "0.1");

            // load plugins

            Server.Print(License);
            Server.RegisterCommand("smod", smod);

            Verifier = new Verifier(Directory.GetCurrentDirectory(), Server.GameDirectory);

            try {
                var doc = new System.Xml.XmlDocument();
                doc.Load(Path.Combine(Server.ModDirectory, Path.Combine("cfg", "databases.xml")));
                try {
                    Database = DefaultDatabase.Load(Path.Combine(Server.ModDirectory, "SharpMod.Database.MySql.dll"));
                    Database.Load(doc);
                } catch (Exception e) {
                    Server.LogError("Database Interface failed to load, using default: {0}", e.Message);
                    Database = new DefaultDatabase();
                    Database.Load(doc);
                }
            } catch (Exception e) {
                Server.LogError("Failed to load cfg/databases.xml: {0}", e.Message);
            }

            Message.Init();
            MapCycle.Init();
        }
开发者ID:txdv,项目名称:sharpmod,代码行数:29,代码来源:SharpMod.cs

示例13: reload_Click

        private void reload_Click(object sender, EventArgs e)
        {
            String firstNum, lastNum;

            // Gets the first 4 and last 4 numbers from the Selectionbox, and saves them to a variable
            firstNum = resolutionSelect.Text.Substring(0, 4);
            lastNum = resolutionSelect.Text.Substring(Math.Max(0, resolutionSelect.Text.Length - 4));

            // Removes any spaces from the above strings.
            firstNum = firstNum.Replace(" ", "");
            lastNum = lastNum.Replace(" ", "");

            // Loads the Application Settings XML file
            System.Xml.XmlDocument appConfigXML = new System.Xml.XmlDocument();
            System.Xml.XmlDocument serConfigXML = new System.Xml.XmlDocument();
            appConfigXML.Load(Game._path + "\\Content\\ApplicationSettings.xml");
            serConfigXML.Load(Game._path + "\\Content\\ServiceSettings.xml");

            // Sets the XML attributes to the current values of the editor
            appConfigXML.SelectSingleNode("//ScreenTitle").InnerText = windowTitleBox.Text;
            appConfigXML.SelectSingleNode("//FullScreen").InnerText = isFullScreen.Text;
            appConfigXML.SelectSingleNode("//ScreenWidth").InnerText = Convert.ToString(firstNum);
            appConfigXML.SelectSingleNode("//ScreenHeight").InnerText = Convert.ToString(lastNum);

            // Saves the Application Settings XML file
            appConfigXML.Save(Game._path + "\\Content\\ApplicationSettings.xml");
            serConfigXML.Save(Game._path + "\\Content\\ServiceSettings.xml");

            MessageBox.Show("Reload Application for changes to take effect");
            System.Diagnostics.Process.Start(Game._path + @"\\Devoxelation.exe");
            Application.Exit();
        }
开发者ID:Bigtalljosh,项目名称:Devoxelation,代码行数:32,代码来源:SettingsEditor.cs

示例14: coverfromxml

        public int coverfromxml(MemoryStream xmlStream)
        {
            int answer = 0;
            try
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                xmlStream.Position = 0;
                doc.Load(xmlStream);
                System.Xml.XmlNode nderoot = doc.SelectSingleNode("/ComicInfo/Pages");
                if (nderoot != null)
                {
                    if (nderoot.ChildNodes.Count > 1)
                    { answer = Convert.ToInt16(nderoot.FirstChild.Attributes.GetNamedItem("Image").Value); }
                    answer = MultipleCovers(answer, nderoot);
                }
                else
                {
                    answer = -1;
                }

            }
            catch (Exception ex)
                {
                    Log.Instance.Write("XML Error! ", ex);
                    answer = -1;
                }
            return answer;
        }
开发者ID:greenstyle,项目名称:yetanotherphotoscreensavercomicedition,代码行数:28,代码来源:ComicImageSource.cs

示例15: GetSmsCount

        /// <summary>
        /// ��ȡ�������
        /// </summary>
        /// <param name="SiteID"></param>
        /// <returns></returns>
        public static string GetSmsCount(string SiteID)
        {
            string UserName = "";
            string Password = "";

            string mToUrl = "";	    //�������õ�url
            string mRtv = "";		//���õķ����ַ���

            string strSMSConfigPath = System.Web.HttpContext.Current.Server.MapPath("/Admin/Config/" + SiteID + "/SiteConfig.config");
            if (System.IO.File.Exists(strSMSConfigPath))
            {
                System.Xml.XmlDocument XDTop = new System.Xml.XmlDocument();
                XDTop.Load(strSMSConfigPath);

                UserName = XDTop.SelectSingleNode("DB/SMSConfig/SMSUserName").InnerText;
                Password = XDTop.SelectSingleNode("DB/SMSConfig/SMSPassword").InnerText;
            }

            // �û�����
            mToUrl = "http://www.139000.com/send/getfee.asp?name=" + UserName + "&pwd=" + Password;

            System.Net.HttpWebResponse rs = (System.Net.HttpWebResponse)System.Net.HttpWebRequest.Create(mToUrl).GetResponse();
            System.IO.StreamReader sr = new System.IO.StreamReader(rs.GetResponseStream(), System.Text.Encoding.Default);
            mRtv = sr.ReadToEnd();

            string[] arr = mRtv.Split(new char[] { '=', '&' });

            return arr[1];
        }
开发者ID:zhanglc8801,项目名称:WKT2015,代码行数:34,代码来源:SmsHelper.cs


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