System.Xml.XPath.XPathNavigator.Select C# (CSharp) Method

Select() public method

public Select ( XPathExpression expr ) : XPathNodeIterator
expr XPathExpression
return XPathNodeIterator
        public virtual XPathNodeIterator Select(XPathExpression expr)
        {
            Contract.Ensures(Contract.Result<XPathNodeIterator>() != null);

            XPathNodeIterator result = Evaluate(expr) as XPathNodeIterator;
            if (result == null)
            {
                throw XPathException.Create(SR.Xp_NodeSetExpected);
            }
            return result;
        }

Same methods

XPathNavigator::Select ( string xpath ) : XPathNodeIterator
XPathNavigator::Select ( string xpath, IXmlNamespaceResolver resolver ) : XPathNodeIterator

Usage Example

		public ForEachComponent (BuildAssembler assembler, XPathNavigator configuration) : base(assembler, configuration) {

            // set up the context
            XPathNodeIterator context_nodes = configuration.Select("context");
            foreach (XPathNavigator context_node in context_nodes)
            {
                string prefix = context_node.GetAttribute("prefix", String.Empty);
                string name = context_node.GetAttribute("name", String.Empty);
                context.AddNamespace(prefix, name);
            }

			// load the expression format
			XPathNavigator variable_node = configuration.SelectSingleNode("variable");
			if (variable_node == null) throw new ConfigurationErrorsException("When instantiating a ForEach component, you must specify a variable using the <variable> element.");
			string xpath_format = variable_node.GetAttribute("expression", String.Empty);
			if ((xpath_format == null) || (xpath_format.Length == 0)) throw new ConfigurationErrorsException("When instantiating a ForEach component, you must specify a variable expression using the expression attribute");
			xpath = XPathExpression.Compile(xpath_format);

			// load the subcomponents
			WriteMessage(MessageLevel.Info, "Loading subcomponents.");
			XPathNavigator components_node = configuration.SelectSingleNode("components");
			if (components_node == null) throw new ConfigurationErrorsException("When instantiating a ForEach component, you must specify subcomponents using the <components> element.");
			
			components = BuildAssembler.LoadComponents(components_node);

			WriteMessage(MessageLevel.Info, String.Format("Loaded {0} subcomponents.", components.Count));

		}
All Usage Examples Of System.Xml.XPath.XPathNavigator::Select