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


C# XPathNavigator.Select方法代码示例

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


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

示例1: ForEachComponent

		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));

		}
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:28,代码来源:ForEachComponent.cs

示例2: BusinessRulesNode

        public BusinessRulesNode(XPathNavigator node, object aSetId)
        {
            XPathNodeIterator selectedNodes;
            if (aSetId == null)
                selectedNodes = node.Select("*[count(ancestor-or-self::" + SET + ")=0]");
            else
                selectedNodes = node.Select("*[count(ancestor-or-self::" + SET + ")=0] | " + SET + "[@" + SET_ATTRS.ID + "='" + aSetId + "']/*");

            PopulateSubNodes(selectedNodes, aSetId);
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:10,代码来源:BusinessRulesNode.cs

示例3: CreateArticlesIterator

 protected override XPathNodeIterator CreateArticlesIterator(Site s, XPathNavigator navigator)
 {
     // RSS
     XPathNodeIterator output = navigator.Select("/rss/channel/item");
     if (output.Count == 0)
     {
         // ATOM
         output = navigator.Select("/atom:feed/atom:entry", xmlnsManager);
     }
     return output;
 }
开发者ID:nnovic,项目名称:GetFacts,代码行数:11,代码来源:RssFetcher.cs

示例4: SharedContentComponent

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

			// get context
			context = GetContext(configuration);

			// get the tags to be resolved
			XPathNodeIterator resolve_nodes = configuration.Select("replace");
			foreach (XPathNavigator resolve_node in resolve_nodes) {
				string path = resolve_node.GetAttribute("elements", String.Empty);
				if (String.IsNullOrEmpty(path)) path = "//(include|includeAttribute)";
				// if (String.IsNullOrEmpty(path)) WriteMessage(MessageLevel.Error, "Each resolve element must contain a path attribute specifying an XPath expression for shared content elements.");
				try {
					XPathExpression path_expresion = XPathExpression.Compile(path, context);
				} catch (XPathException) {
					WriteMessage(MessageLevel.Error, String.Format("The elements expression '{0}' is not a valid XPath.", path));
				}

				string item = resolve_node.GetAttribute("item", String.Empty);
				if (String.IsNullOrEmpty(item)) item = "string(@item)";
				try {
					XPathExpression item_expression = XPathExpression.Compile(item, context);
				} catch (XPathException) {
					WriteMessage(MessageLevel.Error, String.Format("The item expression '{0}' is not a valid XPath.", item));
				}

				string parameters = resolve_node.GetAttribute("parameters", String.Empty);
				if (String.IsNullOrEmpty(parameters)) parameters = "parameter";

				string attribute = resolve_node.GetAttribute("attribute", String.Empty);
				if (String.IsNullOrEmpty(attribute)) attribute = "string(@name)";

				elements.Add( new SharedContentElement(path, item, parameters, attribute, context) );
			}

			// Console.WriteLine("{0} elements explicitly defined", elements.Count);

			if (elements.Count == 0) elements.Add( new SharedContentElement(@"//include | //includeAttribute", "string(@item)", "parameter", "string(@name)", context) );

			// get the source and target formats
			XPathNodeIterator content_nodes = configuration.Select("content");
			foreach (XPathNavigator content_node in content_nodes)
            {
                // get the files				
                string sharedContentFiles = content_node.GetAttribute("file", String.Empty);
                if (String.IsNullOrEmpty(sharedContentFiles))
                    WriteMessage(MessageLevel.Error, "The content/@file attribute must specify a path.");
                ParseDocuments(sharedContentFiles);
            }
            WriteMessage(MessageLevel.Info, String.Format("Loaded {0} shared content items.", content.Count));
		}
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:50,代码来源:SharedContentComponent.cs

示例5: ReadConfiguration

		public void ReadConfiguration (XPathNavigator nav)
		{
			name = Helpers.GetRequiredNonEmptyAttribute (nav, "name");
			
			requirements = new Section ();
			Helpers.BuildSectionTree (nav.Select ("requires/section[string-length(@name) > 0]"), requirements);

			XPathNodeIterator iter = nav.Select ("contents/text()");
			StringBuilder sb = new StringBuilder ();
			
			while (iter.MoveNext ())
				sb.Append (iter.Current.Value);
			if (sb.Length > 0)
				contents = sb.ToString ();
		}
开发者ID:nobled,项目名称:mono,代码行数:15,代码来源:ConfigBlockNodeHandler.cs

示例6: CopyFromFileComponent

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

			if (configuration == null) throw new ArgumentNullException("configuration");

			string data_name = null;

			// get information about the data file
			XPathNodeIterator data_nodes = configuration.Select("data");
			foreach (XPathNavigator data_node in data_nodes) {
				string data_file = data_node.GetAttribute("file", String.Empty);
				if (String.IsNullOrEmpty(data_file)) WriteMessage(MessageLevel.Error, "Data elements must have a file attribute specifying a file from which to load data.");
				data_file = Environment.ExpandEnvironmentVariables(data_file);

				data_name = data_node.GetAttribute("name", String.Empty);
				if (String.IsNullOrEmpty(data_name)) data_name = Guid.NewGuid().ToString();

				// load a schema, if one is specified
				string schema_file = data_node.GetAttribute("schema", String.Empty);
				XmlReaderSettings settings = new XmlReaderSettings();
				if (!String.IsNullOrEmpty(schema_file)) {
					settings.Schemas.Add(null, schema_file);
				}

				// load the document
				WriteMessage(MessageLevel.Info, String.Format("Loading data file '{0}'.", data_file) );
				using (XmlReader reader = XmlReader.Create(data_file, settings)) {
					XPathDocument data_document = new XPathDocument(reader);
					Data.Add(data_name, data_document);
				}
			}
			

			// get the source and target expressions for each copy command
			XPathNodeIterator copy_nodes = configuration.Select("copy");
			foreach (XPathNavigator copy_node in copy_nodes) {
				string source_name = copy_node.GetAttribute("name", String.Empty);
				if (String.IsNullOrEmpty(source_name)) source_name = data_name;

				XPathDocument source_document = (XPathDocument) Data[source_name];

				string source_xpath = copy_node.GetAttribute("source", String.Empty);
				if (String.IsNullOrEmpty(source_xpath)) throw new ConfigurationErrorsException("When instantiating a CopyFromFile component, you must specify a source xpath format using the source attribute.");
				string target_xpath = copy_node.GetAttribute("target", String.Empty);
				if (String.IsNullOrEmpty(target_xpath)) throw new ConfigurationErrorsException("When instantiating a CopyFromFile component, you must specify a target xpath format using the target attribute.");
				copy_commands.Add( new CopyFromFileCommand(source_document, source_xpath, target_xpath) );
			}

		}
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:48,代码来源:CopyFromFileComponent.cs

示例7: IntellisenseComponent

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

			XPathNavigator output_node = configuration.SelectSingleNode("output");
			if (output_node != null) {
                
				string directory_value = output_node.GetAttribute("directory", String.Empty);
				if (!String.IsNullOrEmpty(directory_value)) {
					directory = Environment.ExpandEnvironmentVariables(directory_value);
					if (!Directory.Exists(directory)) WriteMessage(MessageLevel.Error, String.Format("The output directory '{0}' does not exist.", directory));
				}
			}

            // a way to get additional information into the intellisense file
            XPathNodeIterator input_nodes = configuration.Select("input");
            foreach (XPathNavigator input_node in input_nodes) {
                string file_value = input_node.GetAttribute("file", String.Empty);
                if (!String.IsNullOrEmpty(file_value)) {
                    string file = Environment.ExpandEnvironmentVariables(file_value);
                    ReadInputFile(file);
                }
            }

			context.AddNamespace("ddue", "http://ddue.schemas.microsoft.com/authoring/2003/5");

			summaryExpression.SetContext(context);
            memberSummaryExpression.SetContext(context);
			returnsExpression.SetContext(context);
			parametersExpression.SetContext(context);
			parameterNameExpression.SetContext(context);
            templatesExpression.SetContext(context);
            templateNameExpression.SetContext(context);
            exceptionExpression.SetContext(context);
            exceptionCrefExpression.SetContext(context);
        }
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:34,代码来源:IntellisenseComponent.cs

示例8: ParseMappings

		private void ParseMappings(XPathNavigator navigator)
		{
			XPathNodeIterator xpni = navigator.Select(CfgXmlHelper.SessionFactoryMappingsExpression);
			while (xpni.MoveNext())
			{
				MappingConfiguration mc = new MappingConfiguration(xpni.Current);
				if (!mc.IsEmpty())
				{
					// Workaround add first an assembly&resource and then only the same assembly. 
					// the <mapping> of whole assembly is ignored (included only sigles resources)
					// The "ignore" log, is enough ?
					// Perhaps we can add some intelligence to remove single resource reference when a whole assembly is referenced
					//if (!mappings.Contains(mc))
					//{
					//  mappings.Add(mc);
					//}
					//else
					//{
					//  string logMessage = "Ignored mapping -> " + mc.ToString();
					//  if (log.IsDebugEnabled)
					//    log.Debug(logMessage);
					//  if (log.IsWarnEnabled)
					//    log.Warn(logMessage);
					//}

					// The control to prevent mappings duplication was removed since the engine do the right thing 
					// for this issue (simple is better)
					mappings.Add(mc);
				}
			}
		}
开发者ID:ray2006,项目名称:WCell,代码行数:31,代码来源:SessionFactoryConfiguration.cs

示例9: Episode

        public Episode(FileInfo file, Season seasonparent)
            : base(file.Directory)
        {
            String xmlpath = file.Directory.FullName + "/metadata/" + Path.GetFileNameWithoutExtension(file.FullName) + ".xml";
            if (!File.Exists(xmlpath))
            {
                Valid = false;
                return;
            }
            EpisodeXml = new XPathDocument(xmlpath);
            EpisodeNav = EpisodeXml.CreateNavigator();
            EpisodeFile = file;

            _season = seasonparent;

            transX = 200;
            transY = 100;

            backdropImage = _season.backdropImage;

            XPathNodeIterator nodes = EpisodeNav.Select("//EpisodeID");
            nodes.MoveNext();
            folderImage = file.Directory.FullName + "/metadata/" + nodes.Current.Value + ".jpg";

            if (!File.Exists(folderImage))
                folderImage = "/Images/nothumb.jpg";
            title = this.asTitle();

            videoURL = EpisodeFile.FullName;

            LoadImage(folderImage);
        }
开发者ID:fivesixty,项目名称:StandaloneMB,代码行数:32,代码来源:Episode.cs

示例10: GetLanguage

 public XPathNodeIterator GetLanguage()
 {
     XPathDocument doc = new XPathDocument(this.language_support_file);
     nav = doc.CreateNavigator();
     XPathNodeIterator nodes = nav.Select("/lang_support/lang");
     return nodes;
 }
开发者ID:BGCX261,项目名称:zlap-svn-to-git,代码行数:7,代码来源:Language.cs

示例11: CreateAllowedValueRange

 internal static CpAllowedValueRange CreateAllowedValueRange(XPathNavigator allowedValueRangeElementNav, IXmlNamespaceResolver nsmgr)
 {
   XPathNodeIterator minIt = allowedValueRangeElementNav.Select("s:minimum", nsmgr);
   if (!minIt.MoveNext())
     return null;
   double min = Convert.ToDouble(ParserHelper.SelectText(minIt.Current, "text()", null));
   XPathNodeIterator maxIt = allowedValueRangeElementNav.Select("s:maximum", nsmgr);
   if (!maxIt.MoveNext())
     return null;
   double max = Convert.ToDouble(ParserHelper.SelectText(maxIt.Current, "text()", null));
   XPathNodeIterator stepIt = allowedValueRangeElementNav.Select("s:step", nsmgr);
   double? step = null;
   if (stepIt.MoveNext())
     step = Convert.ToDouble(ParserHelper.SelectText(stepIt.Current, "text()", null));
   return new CpAllowedValueRange(min, max, step);
 }
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:16,代码来源:CpAllowedValueRange.cs

示例12: AssertSequencePoints

        protected override void AssertSequencePoints(XPathNavigator navigator)
        {
            var entries = navigator.Select(
                "./symbols/methods/method[@name=\"MethodWithTryCatchFinally.SimpleClass.Divide\"]/sequencepoints/entry");
            Assert.Equal(12, entries.Count);

            int visitedCount = 0;

            foreach (XPathNavigator entry in entries)
            {
                if (entry.GetAttribute("il_offset", string.Empty) == "0x0")
                {
                    Assert.Equal("20", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("20", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("6", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("23", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
                else if (entry.GetAttribute("il_offset", string.Empty) == "0x2c")
                {
                    Assert.Equal("42", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("42", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("4", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("17", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
            }

            Assert.Equal(2, visitedCount);
        }
开发者ID:JasonBock,项目名称:EmitDebugging,代码行数:30,代码来源:DebuggingWithTryCatchFinallyTests.cs

示例13: LoadFromXml

 public override void LoadFromXml(XPathNavigator xml, string prefix)
 {
     XPathNodeIterator iterator = xml.Select(
         prefix + GetType().FullName + "/" + GetType().Namespace + ".KeyTimer"
     );
     int i = 0;
     while (iterator.MoveNext())
     {
         if (i >= KeyTimers.Count)
         {
             Add();
         }
         KeyTimer kt = KeyTimers[i];
         kt.Active = iterator.Current.GetAttribute("Active", "").ToLower() == "true";
         kt.Interval = Convert.ToInt32(iterator.Current.GetAttribute("Interval", ""));
         kt.Key = Convert.ToInt32(iterator.Current.GetAttribute("Key", ""));
         string startTime = iterator.Current.GetAttribute("StartTime", "");
         if (startTime != "")
         {
             DateTime minTime = Convert.ToDateTime("2012-01-01");
             kt.StartTime = Convert.ToDateTime(startTime);
             if (kt.StartTime < minTime)
             {
                 kt.StartTime = DateTime.Now;
             }
         }
         ++i;
     }
 }
开发者ID:quadrowin,项目名称:afkgamer,代码行数:29,代码来源:MdlAutoKeys.cs

示例14: AssertSequencePoints

        protected override void AssertSequencePoints(XPathNavigator navigator)
        {
            var entries = navigator.Select(
                "./symbols/methods/method[@name=\"MethodThatDeclaresLocalsAfterEmittingOpcodes.SimpleClass.ReflectArgument\"]/sequencepoints/entry");
            Assert.Equal(6, entries.Count);

            int visitedCount = 0;

            foreach (XPathNavigator entry in entries)
            {
                if (entry.GetAttribute("il_offset", string.Empty) == "0x0")
                {
                    Assert.Equal("16", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("16", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("4", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("21", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
                else if (entry.GetAttribute("il_offset", string.Empty) == "0x5")
                {
                    Assert.Equal("21", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("21", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("4", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("17", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
            }

            Assert.Equal(2, visitedCount);
        }
开发者ID:JasonBock,项目名称:EmitDebugging,代码行数:30,代码来源:DebuggingWithMethodThatDeclaresLocalsAfterEmittingOpcodes.cs

示例15: AssertSequencePoints

        protected override void AssertSequencePoints(XPathNavigator navigator)
        {
            var entries = navigator.Select(
                "./symbols/methods/method[@name=\"MethodThatWritesLotsOfLocalsToTheConsole.SimpleClass.WriteToConsole\"]/sequencepoints/entry");
            Assert.Equal(6, entries.Count);

            int visitedCount = 0;

            foreach (XPathNavigator entry in entries)
            {
                if (entry.GetAttribute("il_offset", string.Empty) == "0x0")
                {
                    Assert.Equal("16", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("18", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("4", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("76", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
                else if (entry.GetAttribute("il_offset", string.Empty) == "0x38")
                {
                    Assert.Equal("31", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("31", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("4", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("17", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
            }

            Assert.Equal(2, visitedCount);
        }
开发者ID:JasonBock,项目名称:EmitDebugging,代码行数:30,代码来源:DebuggingWithMethodThatWritesLotsOfLocalsToTheConsoleTests.cs


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