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


C# XmlDocument.GetElementById方法代码示例

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


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

示例1: GetNewVersionNumberOfDzenClient

 public static double GetNewVersionNumberOfDzenClient()
 {
     XmlDocument doc = new XmlDocument();
     doc.Load("Configuration.xml");
     double temp = Convert.ToDouble(doc.GetElementById("dzenclient"));
     return temp;
 }
开发者ID:thedzen,项目名称:DzenClient,代码行数:7,代码来源:Server.cs

示例2: ReadFile

        /*
        List<Edit> edits; //everything is stored by edits
        public List<Edit> Edits { get { return edits; } set { edits = value; } }
        */
        //Records when an edit has occured and what the edit was
        //The above structures contain the most updated version of the synthesis
        /*   <localid>rc1</localid>
          <name>benzaldehyde</name>
          <refid>aldehyde</refid>
          <molweight>106.12</molweight>
          <state>solid</state>
          <density temp="20">null</density>
          <islimiting>true</islimiting>
          <mols unit="mmol">57</mols>
          <mass unit="g">6</mass>
          <volume>null</volume>
         * */
        public static Synthesis ReadFile(string filename)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(filename);

            XmlNode header = doc.GetElementById("header");
            XmlNodeList editHeader = doc.GetElementsByTagName("editheader");
            XmlNodeList reactantNodeList = doc.GetElementsByTagName("reactant");
            XmlNodeList reagentNodeList = doc.GetElementsByTagName("reagent");
            XmlNodeList productNodeList = doc.GetElementsByTagName("product");

            ObservableCollection<Compound> reactants = ReadBlock(reactantNodeList, COMPOUND_TYPES.Reactant);
            ObservableCollection<Compound> reagents = ReadBlock(reagentNodeList, COMPOUND_TYPES.Reagent);
            ObservableCollection<Compound> products = ReadBlock(productNodeList, COMPOUND_TYPES.Product);

            string synthName = GetSynthesisName(editHeader);
            int projectID = GetSynthesisProjectID(editHeader);
            SynthesisInfo previousStep = GetPreviousStep(editHeader);
            SynthesisInfo nextStep = GetNextStep(editHeader);
            string procedureText = GetProcedureText(editHeader);
            Synthesis synth = new Synthesis(reactants, reagents, products, synthName, projectID, previousStep, nextStep, procedureText);

            ReadMolData(doc, synth.AllCompounds);
            return synth;
        }
开发者ID:panbaked,项目名称:SynType,代码行数:42,代码来源:SynTypeFileReader.cs

示例3: get

        public virtual Object get()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load("Storage.xml");

            XmlElement xmlElement = doc.GetElementById(guid.ToString());
            return xmlElement;
        }
开发者ID:SaulSilver,项目名称:YachtClub,代码行数:8,代码来源:FileInteraction.cs

示例4: readFilterGraph

 public virtual FilterGraph readFilterGraph(XmlDocument doc)
 {
     FilterGraph result = null;
     if (doc != null)
     {
         result = decodeFilterGraph(doc.GetElementById("graph"), null);
     }
     return result;
 }
开发者ID:agustinsantos,项目名称:mogregis3d,代码行数:9,代码来源:XmlSerializer.cs

示例5: Main

        static void Main()
        {
            string filePath = @"..\..\ch11\booklist.xml";
              XmlDocument xmlDocument = new XmlDocument();
              xmlDocument.Load(filePath);

            XmlElement element = xmlDocument.GetElementById("b2");

            String title = element.FirstChild.FirstChild.Value;
            Console.WriteLine(title);
        }
开发者ID:Choyoungju,项目名称:XMLDTD,代码行数:11,代码来源:FindElementById.cs

示例6: GetInitalXML

        private static XmlNode GetInitalXML()
        {
            var xmlPath = ConfigurationManager.AppSettings["XMLPath"];
            var xmlStartFile = ConfigurationManager.AppSettings["XMLStartupFile"];
            var xmlFileName = Path.Combine(xmlPath, xmlStartFile);
            var doc = new XmlDocument();
            doc.Load(xmlFileName);

            var root = doc.GetElementById("FSMStatus");

            return root;
        }
开发者ID:AbbottF,项目名称:FSM.Manager,代码行数:12,代码来源:XMLManager.cs

示例7: lookup

        public Boolean lookup()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load("Storage.xml");

            if(doc.GetElementById(guid.ToString()) == null){
                return false;
            }
            else{
                return true;
            }
        }
开发者ID:SaulSilver,项目名称:YachtClub,代码行数:12,代码来源:FileInteraction.cs

示例8: add

        public override void add(Guid memberID)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load("Storage.xml");

            XmlNode xmlElement =  doc.GetElementById(memberID.ToString());
            XmlNode x = xmlElement.FirstChild;

            XmlElement newBoat = doc.CreateElement(myGuid.ToString());
            newBoat.SetAttribute(length.ToString(), type.ToString());

            x.AppendChild(newBoat);
        }
开发者ID:SaulSilver,项目名称:YachtClub,代码行数:13,代码来源:Boat.cs

示例9: ReadFile

        // ReadFile function calls Check functions
        // and then reads file and writes it to the target list
        public override void ReadFile(string filepath)
        {
            if (CheckFile(filepath))
            {
                XmlReaderSettings readerSettings = new XmlReaderSettings();
                readerSettings.IgnoreComments = true;
                using (XmlReader reader = XmlReader.Create(filepath, readerSettings))
                {
                    // The load the document DOM
                    XmlDocument document = new XmlDocument();
                    document.Load(reader);

                    // Grab the first node
                    XmlNode mainNode = document.FirstChild;
                    mainNode = mainNode.NextSibling;

                    XmlElement element = document.GetElementById("Targets");

                    // Then get the list of nodes containing the data we want.
                    XmlNodeList nodes = mainNode.ChildNodes; //.ChildNodes;
                    int targetCount = 0;

                    foreach (XmlNode node in nodes)
                    {
                        targetCount++;

                        bool isFriend = Convert.ToBoolean(node.Attributes["isFriend"].Value);
                        double yPos = Convert.ToDouble(node.Attributes["yPos"].Value);
                        double xPos = Convert.ToDouble(node.Attributes["xPos"].Value);
                        double zPos = Convert.ToDouble(node.Attributes["zPos"].Value);
                        string Name = Convert.ToString(node.Attributes["Name"].Value);

                        XmlAttribute attribute = node.Attributes[0];

                        list.Add("Target " + targetCount);
                        list.Add("x = " + xPos);
                        list.Add("y = " + yPos);
                        list.Add("z = " + zPos);
                        list.Add("Friend = " + isFriend);
                        list.Add("Name = " + Name);
                        list.Add("\n");
                    }
                }
            }
        }
开发者ID:proreco,项目名称:ThunderCat,代码行数:47,代码来源:XMLreader.cs

示例10: Sort_Nodes_Benchmark_New

        public void Sort_Nodes_Benchmark_New()
        {
            var xmlContent = GetXmlContent(1);
            var xml = new XmlDocument();
            xml.LoadXml(xmlContent);
            var original = xml.GetElementById(1173.ToString());
            Assert.IsNotNull(original);

            long totalTime = 0;
            var watch = new Stopwatch();
            var iterations = 10000;

            for (var i = 0; i < iterations; i++)
            {
                //don't measure the time for clone!
                var parentNode = (XmlElement)original.Clone();
                watch.Start();
                XmlHelper.SortNodes(
                    parentNode, 
                    "./* [@id]", 
                    element => element.Attribute("id") != null,
                    element => element.AttributeValue<int>("sortOrder"));
                watch.Stop();
                totalTime += watch.ElapsedMilliseconds;
                watch.Reset();

                //do assertions just to make sure it is working properly.
                var currSort = 0;
                foreach (var child in parentNode.SelectNodes("./* [@id]").Cast<XmlNode>())
                {
                    Assert.AreEqual(currSort, int.Parse(child.Attributes["sortOrder"].Value));
                    currSort++;
                }
                //ensure the parent node's properties still exist first
                Assert.AreEqual("content", parentNode.ChildNodes[0].Name);
                Assert.AreEqual("umbracoUrlAlias", parentNode.ChildNodes[1].Name);
                //then the child nodes should come straight after
                Assert.IsTrue(parentNode.ChildNodes[2].Attributes["id"] != null);

            }

            Debug.WriteLine("Total time for " + iterations + " iterations is " + totalTime);
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:43,代码来源:XmlHelperTests.cs

示例11: characterReplace

 /// <summary>
 /// 
 /// 根据课程替换、删除相应的字符
 /// </summary>
 /// <param name="classtype"></param>
 public static void characterReplace(string classtype, ref Word.Document document)
 {
     object missing = System.Reflection.Missing.Value;
     XmlDocument xmldoc = new XmlDocument();
     xmldoc.Load(System.Windows.Forms.Application.StartupPath+"/FilterTemplate.xml");
     XmlNode xmlnode = xmldoc.GetElementById(classtype); //xmldoc.SelectSingleNode("//Template");
     XmlNodeList xmll = xmlnode.ChildNodes;
     for (int i = 0; i < xmll.Count; i++)
     {
         XmlNode xn = xmll[i];
         object text = xn.SelectSingleNode("Replace").InnerText;
         object replacewith = xn.SelectSingleNode("ReplaceFor").InnerText;
         object replace=WdReplace.wdReplaceAll;
         object btrue = true;
         document.Content.Find.ClearFormatting();//移除Find的搜索文本和段落格式设置
         Word.Find find = document.Content.Find;// mainContent1.WordBrowers.document.Content.Find;
         //find.MatchSoundsLike =ref btrue;
         bool b = find.Execute(ref text, ref  missing, ref missing,
             ref  btrue, ref missing, ref missing, ref  missing,
             ref missing, ref missing, ref replacewith,
             ref replace, ref  missing, ref  missing, ref missing, ref missing);
     }
 }
开发者ID:Kristd,项目名称:backup,代码行数:28,代码来源:WordHelper.cs

示例12: SubjectStructure

        private static SubjectStructure subjectPreStructure; //= new SubjectStructure(subjectPre, 1, minisubjectPreStructure);

        #endregion Fields

        #region Constructors

        public MatchArray(string id)
        {
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.Load(Application.StartupPath + "/SpotTemplate.xml");
            //配置共有信息

            //配置对应学科
            XmlElement xmlnode = xmldoc.GetElementById(id); //xmldoc.SelectSingleNode("//Template");
            XmlNode matchSpaceNumnode = xmlnode.SelectSingleNode("matchSpaceNum");
            XmlNode matchSpaceNum2node = xmlnode.SelectSingleNode("matchSpaceNum2");
            XmlNode matchSelectOptionnode = xmlnode.SelectSingleNode("matchSelectOption");
            XmlNode matchSelectOption2node = xmlnode.SelectSingleNode("matchSelectOption2");
            matchSpaceNum = matchSpaceNumnode.InnerText;
            matchSpaceNum2 = matchSpaceNum2node.InnerText;
            matchSelectOption = matchSelectOptionnode.InnerText;
            matchSelectOption2 = matchSelectOption2node.InnerText;

            XmlNode xmlbigSubjectPre = xmlnode.SelectSingleNode("bigSubjectPre");
            bigSubjectPre = xmlbigSubjectPre.InnerText.Split(',');
            XmlNode xmlanswer = xmlnode.SelectSingleNode("answer");
            answer = xmlanswer.InnerText.Split(',');
            XmlNode xmlSubjectStructure = xmlnode.SelectSingleNode("SubjectStructure");
            subjectPreStructure = InitSubjectStructure(xmlSubjectStructure);
        }
开发者ID:Kristd,项目名称:backup,代码行数:30,代码来源:MatchArray.cs

示例13: RemPassWd

 public static bool RemPassWd(string name,string passwd)
 {
     try
     {
         XmlDocument doc = new XmlDocument();
         doc.Load(@"user.xml");
         XmlElement node = doc.GetElementById("user");
         XmlNode nameNode = (XmlNode)doc.GetElementById("username");
         XmlNode passWdNode = (XmlNode)doc.GetElementById("passwd");
         nameNode.InnerText = name;
         passWdNode.InnerText = passwd;
         //node.AppendChild(nameNode);
         //node.AppendChild(passWdNode);
         //doc.DocumentElement.InsertAfter(node, doc.DocumentElement.LastChild);
         doc.Save(@"user.xml");
     }
     catch (Exception exp)
     {
         return false;
     }
     return true;
 }
开发者ID:qq5013,项目名称:Medical,代码行数:22,代码来源:Util.cs

示例14: GetExecutionUrl

        UnifiedResponse IServiceProvider.Search(string query)
        {
            string url = GetExecutionUrl(query);
            var response = new UnifiedResponse();

            string xresp = Http.getText(url);
            if (string.IsNullOrEmpty(xresp))
            {
                response.Success = false;
                response.Error = "No http response from Last.fm API";
                return response;
            }

            var doc = new XmlDocument();
            doc.LoadXml(xresp);

            XmlNode error = doc.GetElementById("error");
            if (error != null)
            {
                response.Success = false;
                response.Error = string.Format(
                    "Last.fm API returns error #{0}: {1}",
                    error.Attributes["code"],
                    error.InnerXml
                );
                return response;
            }

            var nsmanager = new XmlNamespaceManager(doc.NameTable);
            nsmanager.AddNamespace("opensearch", "http://a9.com/-/spec/opensearch/1.1/");

            var countnode = doc.SelectSingleNode("/lfm/results/opensearch:totalResults", nsmanager);
            response.ResultsCount = countnode == null ? 0 : Convert.ToInt32(countnode.InnerXml);

            var results = doc.GetElementsByTagName("album");
            foreach (XmlNode result in results)
            {
                var r = new Result();
                r.Request = query;
                r.Artist  = result["artist"] == null ? string.Empty : result["artist"].InnerText;
                r.Album   = result["name"]   == null ? string.Empty : result["name"]  .InnerText;

                XmlNode urlnode = null;
                if ((urlnode = result.SelectSingleNode("descendant::image[@size='mega']")) != null)
                {
                    r.Width = r.Height = 500;
                }
                else if ((urlnode = result.SelectSingleNode("descendant::image[@size='extralarge']")) != null)
                {
                    r.Width = r.Height = 300;
                }
                else if((urlnode = result.SelectSingleNode("descendant::image[@size='large']")) != null)
                {
                    r.Width = r.Height = 174;
                }

                if (urlnode != null)
                {
                    r.Url = r.Thumb = urlnode.InnerXml;
                }
                response.Results.Add(r);
            }

            return response;
        }
开发者ID:tommiv,项目名称:Artwork-Stack,代码行数:65,代码来源:LastFm.cs

示例15: GetIdElement

 public virtual XmlElement GetIdElement(XmlDocument document, string idValue)
 {
     if (document == null)
     {
         return null;
     }
     XmlElement elementById = document.GetElementById(idValue);
     if (elementById != null)
     {
         return elementById;
     }
     elementById = document.SelectSingleNode("//*[@Id=\"" + idValue + "\"]") as XmlElement;
     if (elementById != null)
     {
         return elementById;
     }
     elementById = document.SelectSingleNode("//*[@id=\"" + idValue + "\"]") as XmlElement;
     if (elementById != null)
     {
         return elementById;
     }
     return (document.SelectSingleNode("//*[@ID=\"" + idValue + "\"]") as XmlElement);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:SignedXml.cs


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