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


C# XPathNavigator.Compile方法代码示例

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


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

示例1: EditCand_Load

        private void EditCand_Load(object sender, EventArgs e)
        {
            doc = new XPathDocument(FILE_NAME);
            nav = doc.CreateNavigator();

            // Compile a standard XPath expression

            expr = nav.Compile("/config/voto/@puesto");
            iterator = nav.Select(expr);

            // Iterate on the node set
            comboBox1.Items.Clear();
            try
            {
                while (iterator.MoveNext())
                {
                    XPathNavigator nav2 = iterator.Current.Clone();
                    comboBox1.Items.Add(nav2.Value);
                    comboBox1.SelectedIndex = 0;

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


            //save old title 
            oldTitle = comboBox1.Text;

        }
开发者ID:ayeec,项目名称:evote,代码行数:32,代码来源:EditCand.cs

示例2: GetAttributes

        /// <summary>
        /// Récupère la valeur de l'attribut du noeud recherché dans le fichier de configuration
        /// </summary>
        /// <param name="xPathString">Expression XPath de recherche du noeud</param>
        /// <param name="attribute">Attribut à rechercher</param>
        /// <returns>Une ArrayList contenant la liste des attributs recherchés</returns>
        public ArrayList GetAttributes(string xPathString, string attribute)
        {
            // Initilisation des variables
                    XPathNodeIterator xpathNodeIterator;
                    XPathExpression expr;

                    ArrayList attributes = new ArrayList();

                    // Parcours du fichier XML
                    try
                    {
                           xpathNavigator = xpathDoc.CreateNavigator();
                           expr = xpathNavigator.Compile(xPathString);
                           xpathNodeIterator = xpathNavigator.Select(expr);

                           while (xpathNodeIterator.MoveNext())
                           {
                                  // On récupère l'attribut
                                  attributes.Add(xpathNodeIterator.Current.GetAttribute(attribute, ""));
                           }
                    }
                    catch (Exception e)
                    {
                    }

                    return attributes;
        }
开发者ID:BackupTheBerlios,项目名称:sofia-svn,代码行数:33,代码来源:XPathNavigatorFacade.cs

示例3: GetValue

 public string GetValue(string xPathString)
 {
     xpathNavigator = xpathDoc.CreateNavigator();
     XPathExpression expr = xpathNavigator.Compile(xPathString);
     XPathNodeIterator xpathNodeIterator = xpathNavigator.Select(expr);
     xpathNodeIterator.MoveNext();
     return xpathNodeIterator.Current.Value;
 }
开发者ID:BackupTheBerlios,项目名称:sofia-svn,代码行数:8,代码来源:XPathNav.cs

示例4: Invoke

 public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext)
 {
     string str = XPathMessageFunction.ToString(args[0]);
     string xpath = string.Format(CultureInfo.InvariantCulture, "/s11:Envelope/s11:Header/*[@s11:actor='{0}'] | /s12:Envelope/s12:Header/*[@s12:role='{1}']", new object[] { str, str });
     XPathExpression expr = docContext.Compile(xpath);
     expr.SetContext((XmlNamespaceManager) xsltContext);
     return docContext.Evaluate(expr);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:XPathMessageFunctionHeadersWithActor.cs

示例5: Select

        static XPathNodeIterator Select(string expression, XPathNavigator source, params XPathVariable[] variables)
		{
			var expr = source.Compile(expression);
			var context = new DynamicContext();
			foreach (var variable in variables)
				context.AddVariable(variable.Name, variable.Value);
			expr.SetContext(context);
			return source.Select(expr);
		}
开发者ID:Jeavon,项目名称:Umbraco-CMS,代码行数:9,代码来源:XmlNodeExtensions.cs

示例6: Invoke

 public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext)
 {
     if (this.expr == null)
     {
         XPathExpression expression = docContext.Compile("(sm:header()/wsa10:FaultTo | sm:header()/wsaAugust2004:FaultTo)[1]");
         expression.SetContext((XmlNamespaceManager) new XPathMessageContext());
         this.expr = expression;
     }
     return docContext.Evaluate(this.expr);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:XPathMessageFunctionFaultTo.cs

示例7: Invoke

 public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext)
 {
     if (this.expr == null)
     {
         XPathExpression expression = docContext.Compile("(/s11:Envelope/s11:Body | /s12:Envelope/s12:Body)[1]");
         expression.SetContext(XPathMessageFunction.Namespaces);
         this.expr = expression;
     }
     return docContext.Evaluate(this.expr);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:XPathMessageFunctionBody.cs

示例8: GetCompiledExpression

		/// <summary>
		/// Retrieves a cached compiled expression, or a newly compiled one.
		/// </summary>
		private static XPathExpression GetCompiledExpression(string expression, XPathNavigator source)
		{
			XPathExpression expr;

			if (!Cache.TryGetValue(expression, out expr))
			{
				// No double checks. At most we will compile twice. No big deal.			  
				expr = source.Compile(expression);
				Cache[expression] = expr;
			}

			return expr.Clone();
		}
开发者ID:kisflying,项目名称:kion,代码行数:16,代码来源:XPathCache.cs

示例9: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            String path = @"..\..\..\data\categories.xml";
            categories = new XPathDocument(path);
            nav = categories.CreateNavigator();
            var expr = nav.Compile("//*");
            XPathNodeIterator iter = nav.Select(expr);
            String category = null;
            List<TreeNode> subcats = new List<TreeNode>() ;
            while (iter.MoveNext())
            {
                if(iter.Current.Name == "cat")
                {
                    if(subcats.Count != 0)
                    {
                        TreeNode cat_node = new TreeNode(category, subcats.ToArray());
                        trv_categories.Nodes.Add(cat_node);
                        subcats.Clear();
                    }
                    category = iter.Current.Value;
                }
                else if(iter.Current.Name == "subcat")
                {
                    subcats.Add(new TreeNode(iter.Current.Value));
                }
            }

            path = @"..\..\..\data\";
            synonyms = new Dictionary<string, List<string>>();
            StreamReader reader = new StreamReader(path+"synonyms.txt", Encoding.UTF8);
            while (!reader.EndOfStream)
            {
                String line = reader.ReadLine();
                if (line.Length <= 0)
                    continue;
                line = line.Trim();
                List<String> syms = line.Split(':','،',',').ToList<String>();
                for (int i = 0; i < syms.Count; i++)
                    syms[i] = syms[i].Trim();
                String key = syms[0];
                syms.RemoveAll(s => s.Length <= 0);
                syms.RemoveAt(0);
                if (synonyms.ContainsKey(key))
                    synonyms[key].Concat(syms);
                else
                    synonyms.Add(key, syms);
            }
        }
开发者ID:imani,项目名称:Estefta,代码行数:48,代码来源:Form1.cs

示例10: Evaluate

        /// <summary>
        /// Evaluates an XPath expression in a newly created context, making additional parameters available to the expression.
        /// </summary>
        /// <param name="nav">
        /// Navigator indicating the current node; if <c>null</c>, a dummy navigator is used.
        /// </param>
        /// <param name="xpathExpr">XPath expression to evaluate.</param>
        /// <param name="param">
        /// Values to be available while evaluating the expression as <c>$paramN</c>, where N is the
        /// index within this array.
        /// </param>
        /// <returns>The result of evaluating the expression</returns>
        public static object Evaluate(XPathNavigator nav, string xpathExpr, params object[] param)
        {
            Checker.NotNull(xpathExpr, "xpathExpr");

            nav = EnsureNavigator(nav);

            var expr = nav.Compile(xpathExpr);

            var context = new TriflesXPathContext();

            int i = 0;
            foreach (var paramN in param)
            {
                context.AddVariable(XNamespace.None + ("param" + i), paramN);
                i++;
            }

            expr.SetContext(context);
            return nav.Evaluate(expr);
        }
开发者ID:falldave,项目名称:falldave-trifles-net,代码行数:32,代码来源:TriflesXPathData.cs

示例11: Invoke

 public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext)
 {
     if (this.expr == null)
     {
         XPathExpression e = docContext.Compile("(sm:header()/wsa10:From | sm:header()/wsaAugust2004:From)[1]");
         e.SetContext(new XPathMessageContext());
         this.expr = e;
     }
     return docContext.Evaluate(this.expr);
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:10,代码来源:XPathMessageContext.cs

示例12: CalculateDrain

	    private int CalculateDrain(XPathNavigator nav, int force)
	    {
	        XPathExpression xprDV;
            // Calculate the Spell's Drain for the current Force.
	        xprDV = nav.Compile(_strDV.Replace("F", force.ToString()).Replace("/", " div "));
	        decimal decDV = Convert.ToDecimal(nav.Evaluate(xprDV)?.ToString());
	        decDV = Math.Floor(decDV);
	        int intDV = Convert.ToInt32(decDV);
	        // Drain cannot be lower than 2.
	        if (intDV < 2)
	            intDV = 2;
	        return intDV;
	    }
开发者ID:GhostWhoWalksInside,项目名称:chummer5a_Dashboard,代码行数:13,代码来源:clsUnique.cs

示例13: PrepareIdNavigator

 /// <summary>
 /// Prepares the Xpath navigator to improve performance for GetNextId().
 /// </summary>
 private void PrepareIdNavigator()
 {
     m_navigator = m_dictionary.CreateNavigator();
     m_expression = m_navigator.Compile(m_basePath);
     m_expression.AddSort(m_XPathId, XmlSortOrder.Descending, XmlCaseOrder.None, String.Empty, XmlDataType.Number);
 }
开发者ID:Stoner19,项目名称:Memory-Lifter,代码行数:9,代码来源:XmlStatistics.cs

示例14: UpdateState


//.........这里部分代码省略.........
            //Change title
            if (name == "FileOrFolderPath" || name == "SearchFor")
            {
                if (string.IsNullOrWhiteSpace(FileOrFolderPath))
                    WindowTitle = "dnGREP";
                else
                    WindowTitle = string.Format("{0} in \"{1}\" - dnGREP", (SearchFor == null ? "Empty" : SearchFor.Replace('\n', ' ').Replace('\r', ' ')), FileOrFolderPath);
            }

            //Change validation
            if (name == "SearchFor" || name == "TypeOfSearch")
            {
                if (string.IsNullOrWhiteSpace(SearchFor))
                {
                    ValidationMessage = "";
                }
                else if (TypeOfSearch == SearchType.Regex)
                {
                    try
                    {
                        Regex regex = new Regex(SearchFor);
                        ValidationMessage = "Regex is OK!";
                    }
                    catch
                    {
                        ValidationMessage = "Regex is not valid!";
                    }
                }
                else if (TypeOfSearch == SearchType.XPath)
                {
                    try
                    {
                        nav = doc.CreateNavigator();
                        XPathExpression expr = nav.Compile(SearchFor);
                        ValidationMessage = "XPath is OK!";
                    }
                    catch
                    {
                        ValidationMessage = "XPath is not valid!";
                    }
                }
                else
                {
                    ValidationMessage = "";
                }
            }

            //Can search
            if (name == "FileOrFolderPath" || name == "CurrentGrepOperation" || name == "SearchFor")
            {
                if (Utils.IsPathValid(FileOrFolderPath) && CurrentGrepOperation == GrepOperation.None &&
                    (!string.IsNullOrEmpty(SearchFor) || settings.Get<bool>(GrepSettings.Key.AllowSearchingForFileNamePattern)))
                {
                    CanSearch = true;
                }
                else
                {
                    CanSearch = false;
                }
                // Refersh buttons
                CommandManager.InvalidateRequerySuggested();
            }

            //Set all files if FileOrFolderPath is a file
            if (name == "FileOrFolderPath")
            {
开发者ID:shu2333,项目名称:dnGrep,代码行数:67,代码来源:BaseMainViewModel.cs

示例15: CreateIterator

        private XPathNodeIterator CreateIterator(string queryString, XPathNavigator nav)
        {
            XPathExpression query = nav.Compile(queryString);
            XPathNodeIterator iter = nav.Select(query);
            return iter;

        }
开发者ID:Yall1963,项目名称:resource-proxy,代码行数:7,代码来源:ReadMetaDataScenario.cs


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