Returns the string result from evaluating an xpath expression against the given document and context. : XPath « XML « C# / C Sharp






Returns the string result from evaluating an xpath expression against the given document and context.

     
// Copyright ? Microsoft Corporation.
// This source file is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.

using System;
using System.Text;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;
using System.Diagnostics;
using System.Collections.Generic;

class Util {

    public static class BuildComponentUtilities {
      /// <summary>
        /// Returns the string result from evaluating an xpath expression against the given document and context.
        /// </summary>
        public static string EvalXPathExpr(IXPathNavigable doc, XPathExpression xpe, CustomContext c) {
            XPathExpression t = xpe.Clone();
            t.SetContext(c);
            return doc.CreateNavigator().Evaluate(t).ToString();
        }

    }

}

   
    
    
    
    
  








Related examples in the same category

1.XPathNavigator
2.XPathNodeIterator
3.Select by path
4.Find Elements with an XPath SearchFind Elements with an XPath Search
5.XPath Query Demo
6.Read XML node using the XML path
7.XmlQuery Example
8. XPath Expression Syntax
9.Using XPath to get string value, integer value and boolean value
10.Extensions.XPathSelectElement selects an XElement using a XPath expression
11.Extensions.XPathSelectElements Selects a collection of elements using an XPath expression.
12.Gets the text value from the element located by the given XPath.
13.Returns the inner text of the single node selected from the specified xpath if found; otherwise, null.
14.Get an array of nodes matching an XPath expression
15.Schema Reference Util