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


C# XNode.XPathEvaluate方法代码示例

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


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

示例1: XPathValues

        //public static IEnumerable<string> XPathValues(XElement xe, string xpath)
        public static IEnumerable<string> XPathValues(XNode node, string xpath)
        {
            if (node == null)
                return new string[0];

            return XPathResultGetValues(node.XPathEvaluate(xpath));
        }
开发者ID:labeuze,项目名称:source,代码行数:8,代码来源:Xml.cs

示例2: XPathElement

        //public static XElement XPathElement(XElement xe, string xpath)
        public static XElement XPathElement(XNode node, string xpath)
        {
            if (node == null)
                return null;

            object xpathResult = node.XPathEvaluate(xpath);
            if (xpathResult is IEnumerable)
            {
                object xpathResult2 = XPathResultGetFirstValue(xpathResult as IEnumerable);
                if (xpathResult2 != null)
                    xpathResult = xpathResult2;
            }
            if (xpathResult is XElement)
                return (XElement)xpathResult;
            else
                return null;
        }
开发者ID:labeuze,项目名称:source,代码行数:18,代码来源:Xml.cs

示例3: XPathValue

        //public static string XPathValue(XElement xe, string xpath, string defaultValue = null)
        public static string XPathValue(XNode node, string xpath, string defaultValue = null)
        {
            if (node == null)
                return defaultValue;

            object xpathResult = node.XPathEvaluate(xpath);
            if (xpathResult is IEnumerable)
            {
                object xpathResult2 = XPathResultGetFirstValue(xpathResult as IEnumerable);
                if (xpathResult2 != null)
                    xpathResult = xpathResult2;
            }
            string value = XPathResultGetValue(xpathResult);
            if (value != null)
                return value;
            else
                return defaultValue;
        }
开发者ID:labeuze,项目名称:source,代码行数:19,代码来源:Xml.cs

示例4: Evaluate

 public override IXsltContextVariable Evaluate(XNode scope, IXmlNamespaceResolver resolver)
 {
     return new ConstantXPathVariable(this.Name, scope.XPathEvaluate(this.ValueExpression, resolver));
 }
开发者ID:LBiNetherlands,项目名称:LBi.LostDoc,代码行数:4,代码来源:ExpressionXPathVariable.cs

示例5: EvalValue

        private static string EvalValue(CustomXsltContext customContext, XNode contextNode, string valueOrExpression)
        {
            // TODO this is quick and dirty
            if (valueOrExpression.StartsWith("{") && valueOrExpression.EndsWith("}"))
            {
                string expression = valueOrExpression.Substring(1, valueOrExpression.Length - 2);
                object value = contextNode.XPathEvaluate(expression, customContext);
                return ResultToString(value);
            }

            return valueOrExpression;
        }
开发者ID:LBiNetherlands,项目名称:LBi.LostDoc,代码行数:12,代码来源:Template.cs

示例6: EvalCondition

 private static bool EvalCondition(CustomXsltContext customContext, XNode contextNode, string condition)
 {
     bool shouldApply;
     if (string.IsNullOrWhiteSpace(condition))
         shouldApply = true;
     else
     {
         object value = contextNode.XPathEvaluate(condition, customContext);
         shouldApply = ResultToBool(value);
     }
     return shouldApply;
 }
开发者ID:LBiNetherlands,项目名称:LBi.LostDoc,代码行数:12,代码来源:Template.cs


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