本文整理汇总了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));
}
示例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;
}
示例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;
}
示例4: Evaluate
public override IXsltContextVariable Evaluate(XNode scope, IXmlNamespaceResolver resolver)
{
return new ConstantXPathVariable(this.Name, scope.XPathEvaluate(this.ValueExpression, resolver));
}
示例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;
}
示例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;
}