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


C# Xml.XmlDocument类代码示例

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


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

示例1: WMIBMySQL

 public WMIBMySQL()
 {
     string file = Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + "unwrittensql.xml";
     Core.RecoverFile(file);
     if (File.Exists(file))
     {
         Syslog.WarningLog("There is a mysql dump file from previous run containing mysql rows that were never successfuly inserted, trying to recover them");
         XmlDocument document = new XmlDocument();
         using (TextReader sr = new StreamReader(file))
         {
             document.Load(sr);
             using (XmlNodeReader reader = new XmlNodeReader(document.DocumentElement))
             {
                 XmlSerializer xs = new XmlSerializer(typeof(Unwritten));
                 Unwritten un = (Unwritten)xs.Deserialize(reader);
                 lock (unwritten.PendingRows)
                 {
                     unwritten.PendingRows.AddRange(un.PendingRows);
                 }
             }
         }
     }
     Thread reco = new Thread(Exec) {Name = "MySQL/Recovery"};
     Core.ThreadManager.RegisterThread(reco);
     reco.Start();
 }
开发者ID:benapetr,项目名称:wikimedia-bot,代码行数:26,代码来源:MySQL.cs

示例2: Save

        public void Save(string path)
        {
            XmlDocument doc = new XmlDocument();
            XmlElement root = doc.CreateElement("Resources");
            doc.AppendChild(root);

            XmlElement sheetsElem = doc.CreateElement("SpriteSheets");
            foreach (KeyValuePair<string, SpriteSheet> pair in SpriteSheets)
            {
                XmlElement elem = doc.CreateElement(pair.Key);
                pair.Value.Save(doc, elem);
                sheetsElem.AppendChild(elem);
            }
            root.AppendChild(sheetsElem);

            XmlElement spritesElem = doc.CreateElement("Sprites");
            foreach (KeyValuePair<string, Sprite> pair in Sprites)
            {
                XmlElement elem = doc.CreateElement(pair.Key);
                pair.Value.Save(doc, elem);
                spritesElem.AppendChild(elem);
            }
            root.AppendChild(spritesElem);

            XmlElement animsElem = doc.CreateElement("Animations");
            foreach (KeyValuePair<string, Animation> pair in Animations)
            {
                XmlElement elem = doc.CreateElement(pair.Key);
                pair.Value.Save(doc, elem);
                animsElem.AppendChild(elem);
            }
            root.AppendChild(animsElem);

            doc.Save(path);
        }
开发者ID:BlaisePascalSi,项目名称:PokeSi,代码行数:35,代码来源:Resources.cs

示例3: Page_Load

		private void Page_Load(object sender, EventArgs e)
		{
			XmlDocument configDoc = new XmlDocument();
			configDoc.Load(Server.MapPath(Configuration.ConfigFile));
			Configuration configuration = new Configuration(configDoc);
			treeNavigator.ContentFile = configuration.ExamplesDataFile;
		}
开发者ID:Letractively,项目名称:henoch,代码行数:7,代码来源:ExamplesNavigation.cs

示例4: New

		/// <summary>
		/// Load the style from assmebly resource.
		/// </summary>
		public virtual void New()
		{
			Assembly ass		= Assembly.GetExecutingAssembly();
			Stream str			= ass.GetManifestResourceStream("AODL.Resources.OD.manifest.xml");
			this.Manifest		= new XmlDocument();
			this.Manifest.Load(str);
		}
开发者ID:rabidbob,项目名称:aodl-reloaded,代码行数:10,代码来源:DocumentManifest.cs

示例5: SetXpdlCache

        /// <summary>
        /// 设置流程文件缓存
        /// </summary>
        /// <param name="processGUID"></param>
        /// <param name="xmlDoc"></param>
        /// <returns></returns>
        internal static XmlDocument SetXpdlCache(string processGUID, string version, XmlDocument xmlDoc)
        {
            var str = processGUID + version;
            var strMD5 = MD5Helper.GetMD5(str);

            return _xpdlCache.GetOrAdd(strMD5, xmlDoc);
        }
开发者ID:uname-yang,项目名称:WorkFlow-Engine-OData-WebApi-with-OdataClient,代码行数:13,代码来源:CachedHelper.cs

示例6: CreateMapping

 public override object[] CreateMapping(params object[] initParams)
 {
     XmlDocument document = (XmlDocument) initParams[0];
     string str = (string) initParams[1];
     DataSet mappingSet = this.GetMappingSet();
     XmlDocument indexesDoc = new XmlDocument();
     indexesDoc.Load(Path.Combine(str, "indexes.xml"));
     foreach (XmlNode node in document.DocumentElement.SelectNodes("//type"))
     {
         DataRow row = mappingSet.Tables["types"].NewRow();
         int mappedTypeId = int.Parse(node.Attributes["mappedTypeId"].Value);
         int num2 = int.Parse(node.Attributes["selectedTypeId"].Value);
         row["MappedTypeId"] = mappedTypeId;
         row["SelectedTypeId"] = num2;
         if (num2 == 0)
         {
             XmlNode node2 = indexesDoc.SelectSingleNode("//type[typeId[text()='" + mappedTypeId + "']]");
             row["TypeName"] = node2.SelectSingleNode("typeName").InnerText;
             row["Remark"] = node2.SelectSingleNode("remark").InnerText;
         }
         mappingSet.Tables["types"].Rows.Add(row);
         XmlNodeList attributeNodeList = node.SelectNodes("attributes/attribute");
         this.MappingAttributes(mappedTypeId, mappingSet, attributeNodeList, indexesDoc, str);
     }
     mappingSet.AcceptChanges();
     return new object[] { mappingSet };
 }
开发者ID:davinx,项目名称:himedi,代码行数:27,代码来源:Yfx1_2_from_Yfx1_2.cs

示例7: saveXml

 private void saveXml()
 {
     string error = String.Empty;
     XmlDocument modifiedXml = new XmlDocument();
     modifiedXml.LoadXml(txtXml.Text);
     pageNode.SetPersonalizationFromXml(HttpContext.Current, modifiedXml, out error);
 }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:7,代码来源:PageAdminPortlet.cs

示例8: LoadAll

        internal static IList<Test> LoadAll()
        {
            var file = new FileInfo("tests.xml");

            if (!file.Exists)
                return new Test[0];

            XmlDocument xml = new XmlDocument();
            using (var fs = file.OpenRead())
                xml.Load(fs);

            var ret = new List<Test>();
            foreach (XmlNode node in xml.SelectNodes("/Tests/*"))
            {
                var n = node.SelectSingleNode("./Type");

                if (n == null)
                    throw new InvalidOperationException("Test Type must be informed.");

                var typeName = n.InnerText;
                var type = FindType(typeName);

                if (type == null)
                    throw new InvalidOperationException(string.Format("'{0}' is not a valid Test.", typeName));

                var obj = (Test)Activator.CreateInstance(type);
                node.ToEntity(obj);

                ret.Add(obj);
            }

            return ret;
        }
开发者ID:hcesar,项目名称:Chess,代码行数:33,代码来源:Test.cs

示例9: UpdateSagaXMLFile

        public static string UpdateSagaXMLFile(ref DataTable _XMLDt, string XMLpath)
        {
            try
            {
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(XMLpath);

                XmlNode xmlnode = xmldoc.DocumentElement.ChildNodes[0];
                xmlnode["ODBCDriverName"].InnerText = _XMLDt.Rows[0]["ODBCDriverName"].ToString();
                xmlnode["HostName"].InnerText = _XMLDt.Rows[0]["HostName"].ToString();
                xmlnode["ServerName"].InnerText = _XMLDt.Rows[0]["ServerName"].ToString();
                xmlnode["ServiceName"].InnerText = _XMLDt.Rows[0]["ServiceName"].ToString();
                xmlnode["Protocol"].InnerText = _XMLDt.Rows[0]["Protocol"].ToString();
                xmlnode["DatabaseName"].InnerText = _XMLDt.Rows[0]["DatabaseName"].ToString();
                xmlnode["UserId"].InnerText = _XMLDt.Rows[0]["UserId"].ToString();
                xmlnode["Password"].InnerText = _XMLDt.Rows[0]["Password"].ToString();
                xmlnode["ClientLocale"].InnerText = _XMLDt.Rows[0]["ClientLocale"].ToString();
                xmlnode["DatabaseLocale"].InnerText = _XMLDt.Rows[0]["DatabaseLocale"].ToString();

                xmldoc.Save(XMLpath);

                return "";
            }
            catch (Exception err)
            {
                return err.Message;
            }
        }
开发者ID:safaintegrated,项目名称:asm,代码行数:28,代码来源:XML.cs

示例10: LoadXml

        /// <summary>
        /// loads a xml from the web server
        /// </summary>
        /// <param name="_url">URL of the XML file</param>
        /// <returns>A XmlDocument object of the XML file</returns>
        public static XmlDocument LoadXml(string _url)
        {
            var xmlDoc = new XmlDocument();
            
            try
            {
                while (Helper.pingForum("forum.mods.de", 10000) == false)
                {
                    Console.WriteLine("Can't reach forum.mods.de right now, try again in 15 seconds...");
                    System.Threading.Thread.Sleep(15000);
                }

                xmlDoc.Load(_url);
            }
            catch (XmlException)
            {
                while (Helper.pingForum("forum.mods.de", 100000) == false)
                {
                    Console.WriteLine("Can't reach forum.mods.de right now, try again in 15 seconds...");
                    System.Threading.Thread.Sleep(15000);
                }

                WebClient client = new WebClient(); ;
                Stream stream = client.OpenRead(_url);
                StreamReader reader = new StreamReader(stream);
                string content = reader.ReadToEnd();

                content = RemoveTroublesomeCharacters(content);
                xmlDoc.LoadXml(content);
            }

            return xmlDoc;
        }
开发者ID:tpf89,项目名称:mods.de-XML-Parser-for-Windows,代码行数:38,代码来源:Helper.cs

示例11: GeoIP

        public GeoIP()
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://freegeoip.net/xml/");
                request.Proxy = null;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream dataStream = response.GetResponseStream();
                StreamReader reader = new StreamReader(dataStream);
                string responseString = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
                response.Close();

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(responseString);

                WANIP = doc.SelectSingleNode("Response//Ip").InnerXml.ToString();
                Country = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryName").InnerXml.ToString())) ? doc.SelectSingleNode("Response//CountryName").InnerXml.ToString() : "Unknown";
                CountryCode = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryCode").InnerXml.ToString())) ? doc.SelectSingleNode("Response//CountryCode").InnerXml.ToString() : "-";
                Region = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//RegionName").InnerXml.ToString())) ? doc.SelectSingleNode("Response//RegionName").InnerXml.ToString() : "Unknown";
                City = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//City").InnerXml.ToString())) ? doc.SelectSingleNode("Response//City").InnerXml.ToString() : "Unknown";
            }
            catch
            {
                WANIP = "-";
                Country = "Unknown";
                CountryCode = "-";
                Region = "Unknown";
                City = "Unknown";
            }
        }
开发者ID:kr-app-a72,项目名称:Computer-Info,代码行数:32,代码来源:GeoIP.cs

示例12: StudyDeleteRecord

 public StudyDeleteRecord(
      String _studyInstanceUid_
     ,DateTime _timestamp_
     ,String _serverPartitionAE_
     ,ServerEntityKey _filesystemKey_
     ,String _backupPath_
     ,String _reason_
     ,String _accessionNumber_
     ,String _patientId_
     ,String _patientsName_
     ,String _studyId_
     ,String _studyDescription_
     ,String _studyDate_
     ,String _studyTime_
     ,XmlDocument _archiveInfo_
     ,String _extendedInfo_
     ):base("StudyDeleteRecord")
 {
     StudyInstanceUid = _studyInstanceUid_;
     Timestamp = _timestamp_;
     ServerPartitionAE = _serverPartitionAE_;
     FilesystemKey = _filesystemKey_;
     BackupPath = _backupPath_;
     Reason = _reason_;
     AccessionNumber = _accessionNumber_;
     PatientId = _patientId_;
     PatientsName = _patientsName_;
     StudyId = _studyId_;
     StudyDescription = _studyDescription_;
     StudyDate = _studyDate_;
     StudyTime = _studyTime_;
     ArchiveInfo = _archiveInfo_;
     ExtendedInfo = _extendedInfo_;
 }
开发者ID:nhannd,项目名称:Xian,代码行数:34,代码来源:StudyDeleteRecord.gen.cs

示例13: DlgTips_Load

        private void DlgTips_Load(object sender, EventArgs e)
        {   
            try
            {
                string strxml = "";
                using (StreamReader streamReader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Johnny.Kaixin.WinUI.Resources.Versions.config")))
                {
                    strxml = streamReader.ReadToEnd();
                }

                XmlDocument objXmlDoc = new XmlDocument();
                objXmlDoc.LoadXml(strxml);

                if (objXmlDoc == null)
                    return;

                DataView dv = GetData(objXmlDoc, "ZrAssistant/Versions");

                for (int ix = 0; ix < dv.Table.Rows.Count; ix++)
                {
                    _versionList.Add(dv.Table.Rows[ix][0].ToString(), dv.Table.Rows[ix][1].ToString());
                    cmbVersion.Items.Add(dv.Table.Rows[ix][0].ToString());
                }

                chkNeverDisplay.Checked = Properties.Settings.Default.NeverDisplay;
                cmbVersion.SelectedIndex = 0;
                SetTextValue();
                btnOk.Select();
            }
            catch (Exception ex)
            {
                Program.ShowMessageBox("DlgTips", ex);
            }
        }
开发者ID:jojozhuang,项目名称:Projects,代码行数:34,代码来源:DlgTips.cs

示例14: AddXmlNodes

        //Appends the any xml file/folder nodes onto the folder
        private void AddXmlNodes(FolderCompareObject folder, int numOfPaths, XmlDocument xmlDoc)
        {
            List<XMLCompareObject> xmlObjList = new List<XMLCompareObject>();
            List<string> xmlFolderList = new List<string>();

            for (int i = 0; i < numOfPaths; i++)
            {
                string path = Path.Combine(folder.GetSmartParentPath(i), folder.Name);

                if (Directory.Exists(path))
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(path);
                    FileInfo[] fileList = dirInfo.GetFiles();
                    DirectoryInfo[] dirInfoList = dirInfo.GetDirectories();
                    string xmlPath = Path.Combine(path, CommonXMLConstants.MetadataPath);

                    if (!File.Exists(xmlPath))
                        continue;

                    CommonMethods.LoadXML(ref xmlDoc, xmlPath);
                    xmlObjList = GetAllFilesInXML(xmlDoc);
                    xmlFolderList = GetAllFoldersInXML(xmlDoc);
                    RemoveSimilarFiles(xmlObjList, fileList);
                    RemoveSimilarFolders(xmlFolderList, dirInfoList);
                }

                AddFileToChild(xmlObjList, folder, i, numOfPaths);
                AddFolderToChild(xmlFolderList, folder, i, numOfPaths);
                xmlObjList.Clear();
                xmlFolderList.Clear();
            }
        }
开发者ID:sr3dna,项目名称:big5sync,代码行数:33,代码来源:XMLMetadataVisitor.cs

示例15: SetValue

        /// <summary>
        /// Define o valor de uma configuração
        /// </summary>
        /// <param name="file">Caminho do arquivo (ex: c:\program.exe.config)</param>
        /// <param name="key">Nome da configuração</param>
        /// <param name="value">Valor a ser salvo</param>
        /// <returns></returns>
        public static bool SetValue(string file, string key, string value)
        {
            var fileDocument = new XmlDocument();
            fileDocument.Load(file);
            var nodes = fileDocument.GetElementsByTagName(AddElementName);

            if (nodes.Count == 0)
            {
                return false;
            }

            for (var i = 0; i < nodes.Count; i++)
            {
                var node = nodes.Item(i);
                if (node == null || node.Attributes == null || node.Attributes.GetNamedItem(KeyPropertyName) == null)
                    continue;
                
                if (node.Attributes.GetNamedItem(KeyPropertyName).Value == key)
                {
                    node.Attributes.GetNamedItem(ValuePropertyName).Value = value;
                }
            }

            var writer = new XmlTextWriter(file, null) { Formatting = Formatting.Indented };
            fileDocument.WriteTo(writer);
            writer.Flush();
            writer.Close();
            return true;
        }
开发者ID:webbers,项目名称:dongle.net,代码行数:36,代码来源:AppConfig.cs


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