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


C# XPathDocument.CreateNavigator方法代码示例

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


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

示例1: ReadDelegates

        public void ReadDelegates(string file, DelegateCollection delegates, string apiname, string apiversions)
        {
            var specs = new XPathDocument(file);

            // The pre-GL4.4 spec format does not distinguish between
            // different apinames (it is assumed that different APIs
            // are stored in distinct signature.xml files).
            // To maintain compatibility, we detect the version of the
            // signatures.xml file and ignore apiname if it is version 1.
            var specversion = GetSpecVersion(specs);
            if (specversion == "1")
            {
                apiname = null;
            }

            foreach (var apiversion in apiversions.Split('|'))
            {
                string xpath_add, xpath_delete;
                GetSignaturePaths(apiname, apiversion, out xpath_add, out xpath_delete);

                foreach (XPathNavigator nav in specs.CreateNavigator().Select(xpath_delete))
                {
                    foreach (XPathNavigator node in nav.SelectChildren("function", String.Empty))
                        delegates.Remove(node.GetAttribute("name", String.Empty));
                }
                foreach (XPathNavigator nav in specs.CreateNavigator().Select(xpath_add))
                {
                    delegates.AddRange(ReadDelegates(nav, apiversion));
                }
            }
        }
开发者ID:jpbruyere,项目名称:opentk,代码行数:31,代码来源:XmlSpecReader.cs

示例2: Main

		static void Main(string[] args)
		{
			PerfTest perf = new PerfTest();
			int repeat = 1000;
			perf.Start();
			XPathDocument doc = new XPathDocument(Globals.GetResource(Globals.NorthwindResource));
			//XmlDocument doc = new XmlDocument();
			//doc.Load("test/northwind.xml");
			Console.WriteLine("Loading XML document: {0, 6:f2} ms", perf.Stop());
			XPathNavigator nav = doc.CreateNavigator();      
			XPathExpression expr = nav.Compile("/ROOT/CustomerIDs/OrderIDs/Item[OrderID=' 10330']/ShipAddress");
      
			Console.WriteLine("Regular selection, warming...");
			SelectNodes(nav, repeat, perf, expr);
			Console.WriteLine("Regular selection, testing...");
			SelectNodes(nav, repeat, perf, expr);
   
      
			perf.Start();
			IndexingXPathNavigator inav = new IndexingXPathNavigator(
				doc.CreateNavigator());
			Console.WriteLine("Building IndexingXPathNavigator: {0, 6:f2} ms", perf.Stop());
			perf.Start();
			inav.AddKey("orderKey", "OrderIDs/Item", "OrderID");
			Console.WriteLine("Adding keys: {0, 6:f2} ms", perf.Stop());    
			XPathExpression expr2 = inav.Compile("key('orderKey', ' 10330')/ShipAddress");
			perf.Start();
			inav.BuildIndexes();
			Console.WriteLine("Indexing: {0, 6:f2} ms", perf.Stop());    
      
			Console.WriteLine("Indexed selection, warming...");
			SelectIndexedNodes(inav, repeat, perf, expr2);
			Console.WriteLine("Indexed selection, testing...");
			SelectIndexedNodes(inav, repeat, perf, expr2);      
		}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:35,代码来源:IndexingXPathNavigatorTest.cs

示例3: ReadDelegates

 public void ReadDelegates(string file, DelegateCollection delegates)
 {
     var specs = new XPathDocument(file);
     foreach (XPathNavigator nav in specs.CreateNavigator().Select("/signatures/delete"))
     {
         foreach (XPathNavigator node in nav.SelectChildren("function", String.Empty))
             delegates.Remove(node.GetAttribute("name", String.Empty));
     }
     foreach (XPathNavigator nav in specs.CreateNavigator().Select("/signatures/add"))
     {
         Utilities.Merge(delegates, ReadDelegates(nav));
     }
 }
开发者ID:hultqvist,项目名称:opentk,代码行数:13,代码来源:XmlSpecReader.cs

示例4: CancelAppointment

        public bool CancelAppointment(HackExchangeContext context, CalendarItem appointment)
        {
            var url = context.Endpoint;
            var request = new HttpRequestMessage(HttpMethod.Post, url);
            var postBodyTemplate = LoadXml("CancelAppointment");
            var postBody = string.Format(postBodyTemplate, appointment.Id, appointment.ChangeKey);
            request.Content = new StringContent(postBody, Encoding.UTF8, "text/xml");

            var clientHandler = new HttpClientHandler()
            {
                Credentials = context.Credentials
            };
            using (var client = new HttpClient(clientHandler))
            {
                var response = client.SendAsync(request).Result;
                var responseBody = response.Content.ReadAsStringAsync().Result;

                var doc = new XPathDocument(new StringReader(responseBody));
                var nav = doc.CreateNavigator();
                var nsManager = new XmlNamespaceManager(nav.NameTable);
                nsManager.AddNamespace("m", "http://schemas.microsoft.com/exchange/services/2006/messages");
                nsManager.AddNamespace("t", "http://schemas.microsoft.com/exchange/services/2006/types");

                var responseClass = EvaluateXPath(nav, nsManager, "//m:DeleteItemResponseMessage/@ResponseClass");
                return responseClass == "Success";
            }
        }
开发者ID:arriori,项目名称:Hackweek2,代码行数:27,代码来源:HackExchangeService.cs

示例5: ResinConf

 public ResinConf(String file)
 {
   _xPathDoc = new XPathDocument(file);
   _docNavigator = _xPathDoc.CreateNavigator();
   _xmlnsMgr = new XmlNamespaceManager(_docNavigator.NameTable);
   _xmlnsMgr.AddNamespace("caucho", "http://caucho.com/ns/resin");
 }
开发者ID:dpitkevics,项目名称:php-to-scala-migration-helper,代码行数:7,代码来源:ResinConf.cs

示例6: PackageInstaller

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// This Constructor creates a new PackageInstaller instance
        /// </summary>
        /// <param name="package">A PackageInfo instance</param>
        /// <history>
        /// 	[cnurse]	01/21/2008  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public PackageInstaller(PackageInfo package)
        {
            IsValid = true;
            DeleteFiles = Null.NullBoolean;
            Package = package;
            if (!string.IsNullOrEmpty(package.Manifest))
            {
				//Create an XPathDocument from the Xml
                var doc = new XPathDocument(new StringReader(package.Manifest));
                XPathNavigator nav = doc.CreateNavigator().SelectSingleNode("package");
                ReadComponents(nav);
            }
            else
            {
                ComponentInstallerBase installer = InstallerFactory.GetInstaller(package.PackageType);
                if (installer != null)
                {
					//Set package
                    installer.Package = package;

                    //Set type
                    installer.Type = package.PackageType;
                    _componentInstallers.Add(0, installer);
                }
            }
        }
开发者ID:rrsc,项目名称:Dnn.Platform,代码行数:35,代码来源:PackageInstaller.cs

示例7: AddTargets

		private void AddTargets (string map, string input, string baseOutputPath, XPathExpression outputXPath, string link, XPathExpression formatXPath, XPathExpression relativeToXPath) {

			XPathDocument document = new XPathDocument(map);

			XPathNodeIterator items = document.CreateNavigator().Select("/*/item");
			foreach (XPathNavigator item in items) {

				string id = (string) item.Evaluate(artIdExpression);
				string file = (string) item.Evaluate(artFileExpression);
				string text = (string) item.Evaluate(artTextExpression);

				id = id.ToLower();
				string name = Path.GetFileName(file);

				ArtTarget target = new ArtTarget();
				target.Id = id;
				target.InputPath = Path.Combine(input, file);
				target.baseOutputPath = baseOutputPath;
                target.OutputXPath = outputXPath;
                
                if (string.IsNullOrEmpty(name)) target.LinkPath = link;
                else target.LinkPath = string.Format("{0}/{1}", link, name);
                
				target.Text = text;
                target.Name = name;
                target.FormatXPath = formatXPath;
                target.RelativeToXPath = relativeToXPath;

				targets[id] = target;
				// targets.Add(id, target);
            }

	    }
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:33,代码来源:ResolveArtLinksComponent.cs

示例8: foreach

        /// <inheritdoc />
        public override XPathNavigator this[string key]
        {
            get
            {
                string xml;

                // Try the in-memory cache first
                XPathNavigator content = base[key];

                // If not found there, try the database caches if there are any
                if(content == null && esentCaches.Count != 0)
                    foreach(var c in esentCaches)
                        if(c.TryGetValue(key, out xml))
                        {
                            // Convert the XML to an XPath navigator
                            using(StringReader textReader = new StringReader(xml))
                                using(XmlReader reader = XmlReader.Create(textReader, settings))
                                {
                                    XPathDocument document = new XPathDocument(reader);
                                    content = document.CreateNavigator();
                                }
                        }

                return content;
            }
        }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:27,代码来源:ESentIndexCache.cs

示例9: DoFindAlbums

        public static List<Album> DoFindAlbums(string artistId, string artistName)
        {
            string uri = string.Format("http://musicbrainz.org/ws/1/artist/{0}?type=xml&inc=sa-Official+release-events", artistId);
              XPathDocument doc = new XPathDocument(uri);
              XPathNavigator nav = doc.CreateNavigator();
              XmlNamespaceManager nsmgr = new XmlNamespaceManager(nav.NameTable);
              string ns = "http://musicbrainz.org/ns/mmd-1.0#";
              nsmgr.AddNamespace("mb", ns);
              XPathNodeIterator ni = nav.Select("//mb:release", nsmgr);
              List<Album> albums = new List<Album>();
              while (ni.MoveNext())
              {
            XPathNavigator current = ni.Current;
            Album album = new Album();
            album.Artist = artistName;
            album.Id = current.GetAttribute("id", string.Empty);
            current.MoveToChild("title", ns);
            album.Title = HttpUtility.HtmlDecode(current.InnerXml);

            current.MoveToParent();
            if (current.MoveToChild("asin", ns))
              album.Asin = current.InnerXml;

            current.MoveToParent();
            if (current.MoveToChild("release-event-list", ns))
            {
              current.MoveToChild("event", ns);
              string s = current.GetAttribute("date", string.Empty); // month and day may be missing
              album.Date = GetDate(s);
            }
            current.MoveToChild("title", ns);
            albums.Add(album);
              }
              return albums;
        }
开发者ID:sethfetzer,项目名称:MusicDB,代码行数:35,代码来源:MusicBrainz.cs

示例10: Load

        public mdnaSettings.Settings Load( string category )
        {
            mdnaSettings.Settings result = new mdnaSettings.Settings();

            XPathDocument doc = new XPathDocument( m_fileName );
            XPathNavigator nav = doc.CreateNavigator();

            // Get the expression compiled.
            // We want all of the nodes in the category regardless of position or their attributes.
            XPathExpression expr;
            expr = nav.Compile( "//"+category );
            XPathNodeIterator iter = nav.Select(expr);

            result.Category = category;

            try
            {
                while( iter.MoveNext() )
                {
                    result.Add( iter.Current.GetAttribute( "name", "" ), iter.Current.GetAttribute( "value", "" ) );
                }
            }
            catch( Exception ex )
            {
                MessageBox.Show( "Exception Caught: " + ex.Message );
            }

            return( result );
        }
开发者ID:jhare,项目名称:MDNA,代码行数:29,代码来源:SettingsFile.cs

示例11: BuildVerifier

		protected BuildVerifier()
		{
			this.m_UnsupportedAssemblies = new Dictionary<string, HashSet<string>>();
			string text = Path.Combine(Path.Combine(EditorApplication.applicationContentsPath, "Resources"), "BuildVerification.xml");
			XPathDocument xPathDocument = new XPathDocument(text);
			XPathNavigator xPathNavigator = xPathDocument.CreateNavigator();
			xPathNavigator.MoveToFirstChild();
			XPathNodeIterator xPathNodeIterator = xPathNavigator.SelectChildren("assembly", string.Empty);
			while (xPathNodeIterator.MoveNext())
			{
				string attribute = xPathNodeIterator.Current.GetAttribute("name", string.Empty);
				if (attribute == null || attribute.Length < 1)
				{
					throw new ApplicationException(string.Format("Failed to load {0}, <assembly> name attribute is empty", text));
				}
				string text2 = xPathNodeIterator.Current.GetAttribute("platform", string.Empty);
				if (text2 == null || text2.Length < 1)
				{
					text2 = "*";
				}
				if (!this.m_UnsupportedAssemblies.ContainsKey(text2))
				{
					this.m_UnsupportedAssemblies.Add(text2, new HashSet<string>());
				}
				this.m_UnsupportedAssemblies[text2].Add(attribute);
			}
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:27,代码来源:BuildVerifier.cs

示例12: ReadXml

        /// <summary>
        /// Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> stream from which the object is deserialized.</param>
        public override void ReadXml(System.Xml.XmlReader reader)
        {
            XPathDocument doc = new XPathDocument(reader);
            XPathNavigator nav = doc.CreateNavigator();

            XPathNavigator iter = nav.SelectSingleNode("Metric/MetricName");
            if (iter != null)
                MetricName = iter.Value;

            iter = nav.SelectSingleNode("Metric/Description");
            if (iter != null)
                Description = iter.Value;

            var serializer = TraceLab.Core.Serialization.XmlSerializerFactory.GetSerializer(typeof(Point), null);
            iter = nav.SelectSingleNode("Metric/Points");
            if (iter != null)
            {
                m_points = new List<Point>();
                XPathNodeIterator pointsNodes = iter.Select("Point");
                while (pointsNodes.MoveNext())
                {
                    var p = (Point)serializer.Deserialize(pointsNodes.Current.ReadSubtree());
                    m_points.Add(p);
                }
            }
        }
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:30,代码来源:LineSeries.cs

示例13: ReadXml

        /// <summary>
        /// Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> stream from which the object is deserialized.</param>
        public override void ReadXml(XmlReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            if (reader.LocalName == "DirectoryPath")
            {
                XmlReader subReader = reader.ReadSubtree();
                XPathDocument doc = new XPathDocument(subReader);
                var nav = doc.CreateNavigator();

                XPathNavigator iter = nav.SelectSingleNode("/DirectoryPath/Version");
                if (iter != null)
                {
                    long ver = iter.ValueAsLong;

                    if (ver == CurrentVersion)
                    {
                        ReadCurrentVersion(nav);
                    }
                    else
                    {
                        throw new NotSupportedException("Version not supported.");
                    }
                }
                else
                {
                    throw new NotSupportedException("Could not read version of DirectoryPath. ");
                }
            }
        }
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:35,代码来源:DirectoryPath.cs

示例14: Setting_the_cache_option_causes_the_results_to_be_cached_in_the_default_directory

        public void Setting_the_cache_option_causes_the_results_to_be_cached_in_the_default_directory()
        {
            // arrange
            var resultsFile = "StyleCop.Cache";
            System.IO.File.Delete(resultsFile);

            // create the activity
            var target = new StyleCop();

            // create a parameter set
            Dictionary<string, object> args = new Dictionary<string, object>
            {
                 { "SourceFiles", new string[] { @"TestFiles\FileWith6Errors.cs" } },
                 { "SettingsFile", @"TestFiles\AllSettingsEnabled.StyleCop" },
                 { "CacheResults", true },
            };

            // Create a WorkflowInvoker and add the IBuildDetail Extension
            WorkflowInvoker invoker = new WorkflowInvoker(target);

            // act
            var results = invoker.Invoke(args);

            // assert
            Assert.IsTrue(System.IO.File.Exists(resultsFile));
            var document = new XPathDocument(resultsFile);
            var nav = document.CreateNavigator();
            Assert.AreEqual(6d, nav.Evaluate("count(/stylecopresultscache/sourcecode/violations/violation)"));
        }
开发者ID:modulexcite,项目名称:CustomActivities,代码行数:29,代码来源:CacheTests.cs

示例15: GetTimeZone

        /// <summary>
        /// Gets the time zone.
        /// </summary>
        /// <param name="offset">The offset.</param>
        /// <returns></returns>
        private static string GetTimeZone(double offset)
        {
            //Adjust result based on the server time zone
            string timeZoneKey = "timeOffset" + offset.ToString("F");
            string result = (CallContext.GetData(timeZoneKey) ?? "").ToString();
            if (result.Length == 0)
            {
                string zonesDocPath = "TimeZones.xml";
                XPathDocument timeZonesDoc = new XPathDocument(zonesDocPath);
                try
                {
                    string xPath = "/root/option[@value='" + offset.ToString("F") + "']";
                    XPathNavigator searchNavigator = timeZonesDoc.CreateNavigator();
                    XmlNamespaceManager nsmgr = new XmlNamespaceManager(searchNavigator.NameTable);
                    XPathNodeIterator iterator = searchNavigator.Select(xPath, nsmgr);
                    if (iterator.MoveNext())
                    {
                        result = iterator.Current.Value;
                        if (!string.IsNullOrEmpty(result))
                        {
                            CallContext.SetData(timeZoneKey, result);
                        }
                    }

                }
                catch (Exception ex)
                {
                    return ex.Message;
                }
            }

            return result;
        }
开发者ID:CamilleValley,项目名称:SnipeAgent,代码行数:38,代码来源:ServiceTimeZone.cs


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