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


C# XPathDocument.Select方法代码示例

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


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

示例1: OSLanguageHelper

        static OSLanguageHelper()
        {
            AvailableUploadEnabledLanguagesList = new Dictionary<String,OSLanguage>();
            AvailableWebEnabledLanguagesList = new Dictionary<String, OSLanguage>();
            AllLanguagesList = new Dictionary<String, OSLanguage>();
            XPathNavigator xmlMetadataNavigator = new XPathDocument(new XmlTextReader(new StringReader(OpenSubtitlesDotNET.Resource.OSLanguageTableDump))).CreateNavigator();
            XPathNodeIterator languagesIter = xmlMetadataNavigator.Select("OSLanguageTableDump/language");
            if (languagesIter.Count > 0)
            {
                while (languagesIter.MoveNext())
                {
                    OSLanguage language = language = new OSLanguage(languagesIter.Current.SelectSingleNode("IdSubLanguage").Value,
                                languagesIter.Current.SelectSingleNode("ISO639").Value,
                                languagesIter.Current.SelectSingleNode("LanguageName").Value,
                                languagesIter.Current.SelectSingleNode("UploadEnabled").Value.Equals("0") ? false : true,
                                languagesIter.Current.SelectSingleNode("WebEnabled").Value.Equals("0") ? false : true);
                    if (!languagesIter.Current.SelectSingleNode("UploadEnabled").Value.Equals("0"))
                    {
                        AvailableUploadEnabledLanguagesList.Add(language.IdSubLanguage,language);
                    }
                    if (!languagesIter.Current.SelectSingleNode("WebEnabled").Value.Equals("0"))
                    {
                        AvailableWebEnabledLanguagesList.Add(language.IdSubLanguage,language);
                    }
                    AllLanguagesList.Add(language.IdSubLanguage, language);
                }
            }

        }
开发者ID:aucan,项目名称:subtitle_downloader,代码行数:29,代码来源:OSLanguageHelper.cs

示例2: GetCsprojNodeIterator

		private static XPathNodeIterator GetCsprojNodeIterator(string select)
		{
			XPathNavigator navigator = new XPathDocument(arguments.ProjectFilePath).CreateNavigator();
			XmlNamespaceManager namespaceManager = new XmlNamespaceManager(navigator.NameTable);
			namespaceManager.AddNamespace("pr", "http://schemas.microsoft.com/developer/msbuild/2003");
			return navigator.Select(select, namespaceManager);
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:7,代码来源:Program.cs

示例3: ProjectList

        public IDictionary<string, string> ProjectList()
        {
            XPathNavigator projects = new XPathDocument(_extractPath + "/desktop.xml").CreateNavigator();
            XPathNodeIterator nodes = projects.Select("/desktops/desktop/@name");
            Dictionary<string, string> result = new Dictionary<string,string>();

            while (nodes.MoveNext())
                result.Add(nodes.CurrentPosition.ToString(), nodes.Current.ToString());
            return result;
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:10,代码来源:RQZkn3.cs

示例4: ParseLibrary

        public void ParseLibrary(string pathName)
        {
            this.Tracks.Clear();

            var navigator = new XPathDocument(pathName).CreateNavigator();
            var iterator = navigator.Select("/plist/dict/dict/dict");
            while (iterator.MoveNext())
            {
                var track = this.parseTrack(iterator.Current.SelectChildren(XPathNodeType.All));
                if (track != null)
                {
                    this.Tracks.Add(track);
                }
            }
        }
开发者ID:TJMicroPower,项目名称:Wheezy.Pivot.NET,代码行数:15,代码来源:ITunesLibraryParse.cs

示例5: GetMapsFromReader

 public static List<MapDescription> GetMapsFromReader(TextReader reader)
 {
     List<MapDescription> mapList = new List<MapDescription>();
     XPathNavigator nav = new XPathDocument(reader).CreateNavigator();
     XPathNodeIterator maps = nav.Select("/maps/map");
     while (maps.MoveNext()) {
         MapDescription map = new MapDescription();
         map.Name = maps.Current.SelectSingleNode("name").Value;
         map.Code = maps.Current.SelectSingleNode("code").Value;
         map.BaseLayer = maps.Current.SelectSingleNode("baseLayer").ValueAsBoolean;
         map.Covered = maps.Current.SelectSingleNode("covered").Value;
         map.Active = maps.Current.SelectSingleNode("active").ValueAsBoolean;
         mapList.Add(map);
     }
     return mapList;
 }
开发者ID:TweetyHH,项目名称:Open-Cache-Manager,代码行数:16,代码来源:MapManager.cs

示例6: LoadXml

 private void LoadXml(XmlReader xmlReader)
 {
     var result = new List<INotifyAction>();
     XPathNavigator nav = new XPathDocument(xmlReader).CreateNavigator();
     var manager = new XmlNamespaceManager(nav.NameTable);
     manager.AddNamespace("act", "urn:asc.notify.action.xsd");
     XPathNodeIterator nodes = nav.Select("act:catalog/action", manager);
     while (nodes.MoveNext())
     {
         result.Add(
             new NotifyAction(
                 nodes.Current.GetAttribute("id", ""),
                 nodes.Current.GetAttribute("name", "")));
     }
     _ConstProvider = new ConstActionProvider(result.ToArray());
 }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:16,代码来源:XmlActionProvider.cs

示例7: FindCompileIncludeFile

        public XPathNodeIterator FindCompileIncludeFile(string includeFile)
        {
            var document = XDocument.Load(projectFile);

            if (document.Root != null)
            {
                var navigator = new XPathDocument(projectFile).CreateNavigator();
                var namespaceManager = new XmlNamespaceManager(navigator.NameTable);
                namespaceManager.AddNamespace("pr", "http://schemas.microsoft.com/developer/msbuild/2003");

                return navigator.Select(
                    @"pr:Project/pr:ItemGroup/pr:Compile[@Include='" + includeFile + "']",
                    namespaceManager);
            }

            return null;
        }
开发者ID:joaofx,项目名称:simpletemplate,代码行数:17,代码来源:Project.cs

示例8: Read

		public static void Read(string filepath, PropertyManager properties, ReferenceTable references, IdTable ids) {
			var xml = new XPathDocument(filepath).CreateNavigator();
			var pi = xml.Select("/Properties/Property");
			while ( pi.MoveNext() ) {
				var pnode = pi.Current;
				var p = properties.Create();
				ids[p] = new Guid(pnode.GetAttribute("id", ""));
				AssignProperties(pnode, p, references);
				var fi = pnode.Select("Flats/Flat");
				while ( fi.MoveNext() ) {
					var fnode = fi.Current;
					var f = p.CreateFlat();
					ids[f] = new Guid(fnode.GetAttribute("id", ""));
					AssignProperties(fnode, f, references);
				}
			}
		}
开发者ID:Wolfury,项目名称:nebenkosten,代码行数:17,代码来源:Xml.cs

示例9: D900CdrDefinitionProvider

        private D900CdrDefinitionProvider(string xmlURI)
        {
            _schemaList = new List<D900CdrDefinitionSchema>();
            _defaultSchema = -1;
            _xmlVersion = String.Empty;

            bool def;

            #if FW35
            XElement cdrXML = XDocument
                .Load(xmlURI, LoadOptions.None)
                .Element("D900Cdr");

            __xmlVersion = cdrXML.Attribute("Version").Value;

            foreach (XElement schXML in cdrXML.Elements("Schema"))
            {
                D900CdrDefinitionSchema sch = new D900CdrDefinitionSchema(schXML.Attribute("Name").Value);
                ReadDefinitions(sch.Definitions, schXML, String.Empty);
                _schemaList.Add(sch);
                Boolean.TryParse(schXML.Attribute("Default").Value, out def);
                if (def) _defaultSchema = _schemaList.Count - 1;
            }
            #else
            XPathNavigator cdrXML = new XPathDocument(xmlURI)
                .CreateNavigator()
                .SelectSingleNode("D900Cdr");

            _xmlVersion = cdrXML.GetAttribute("Version", String.Empty);

            foreach (XPathNavigator schXML in cdrXML.Select("Schema"))
            {
                D900CdrDefinitionSchema sch = new D900CdrDefinitionSchema(schXML.GetAttribute("Name", String.Empty));
                ReadDefinitions(sch.Definitions, schXML, String.Empty);
                _schemaList.Add(sch);
                if (Boolean.TryParse(schXML.GetAttribute("Default", String.Empty), out def) && def)
                {
                    _defaultSchema = _schemaList.Count - 1;
                }
            }
            #endif
            if ((_defaultSchema < 0) && (_schemaList.Count > 0))
                _defaultSchema = 0;
            _currentSchema = _defaultSchema;
        }
开发者ID:neeraj9,项目名称:d900cdr-decoder,代码行数:45,代码来源:D900CdrDefinitionProvider.cs

示例10: Execute

        public override IEnumerable<Row> Execute(IEnumerable<Row> rows) {
            foreach (var row in rows) {
                if (ShouldRun(row)) {
                    var target = string.Empty;
                    var reader = new StringReader(row[InKey].ToString());
                    using (var xmlReader = XmlReader.Create(reader, _settings)) {
                        var navigator = new XPathDocument(xmlReader).CreateNavigator();
                        var result = navigator.Select(_xPath);
                        while (result.MoveNext()) {
                            target += result.Current.Value;
                        }
                    }
                    row[OutKey] = Common.ConversionMap[_outType](target);
                } else {
                    Interlocked.Increment(ref SkipCount);
                }

                yield return row;
            }
        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:20,代码来源:XpathOperation.cs

示例11: PostProcess

        public static void PostProcess(string xsdFile, ref string generatedCode, CodeDomProvider Provider)
        {
            XPathNavigator nav;
            using (FileStream fs = new FileStream(xsdFile, FileMode.Open, FileAccess.Read)) {
                nav = new XPathDocument(fs).CreateNavigator();
            }

            XPathNodeIterator it = nav.Select(PostExts);
            while (it.MoveNext()) {
                Dictionary<string, string> values = ParsePEValue(it.Current.Value);
                Type t = Type.GetType(values["extension-type"], true);
                // Is the type an ICodeExtension?
                Type iface = t.GetInterface(typeof(IPostExtension).Name);
                if (iface == null)
                    throw new ArgumentException(string.Format(Resources.ex_InvalidExtensionType, it.Current.Value));

                IPostExtension ext = (IPostExtension)Activator.CreateInstance(t);
                ext.Initialize(values);
                // Run it!
                ext.PostProcess(ref generatedCode, Provider);
            }
        }
开发者ID:wskplho,项目名称:Tools,代码行数:22,代码来源:Processor.cs

示例12: ReadFrom

        /// <summary>
        /// Creates an <see cref="AtomLink" /> instance from XML.
        /// </summary>
        /// <param name="xmlReader">
        /// The <see cref="XmlReader" /> containing the XML representation of
        /// the Atom Link.
        /// </param>
        /// <returns>
        /// A new instance of <see cref="AtomLink" /> containing the data from
        /// the XML representation of the Atom link contained in
        /// <paramref name="xmlReader" />.
        /// </returns>
        /// <exception cref="System.ArgumentException">
        /// The supplied XML reader contains an atom:link element without an href attribute.
        /// or
        /// The supplied XML reader contains an atom:link element without a rel attribute.
        /// </exception>
        public static AtomLink ReadFrom(XmlReader xmlReader)
        {
            var navigator = new XPathDocument(xmlReader).CreateNavigator();

            var resolver = new XmlNamespaceManager(new NameTable());
            resolver.AddNamespace("atom", "http://www.w3.org/2005/Atom");

            var href = navigator
                .Select("/atom:link/@href", resolver)
                .Cast<XPathNavigator>()
                .Select(x => x.Value)
                .SingleOrDefault();
            if (href == null)
                throw new ArgumentException("The supplied XML reader contains an atom:link element without an href attribute. An atom:link element must have an href attribute.", "xmlReader");

            var rel = navigator
                .Select("/atom:link/@rel", resolver)
                .Cast<XPathNavigator>()
                .Select(x => x.Value)
                .SingleOrDefault();
            if (rel == null)
                throw new ArgumentException("The supplied XML reader contains an atom:link element without a rel attribute. An atom:link element must have a rel attribute.", "xmlReader");

            return new AtomLink(rel, new Uri(href, UriKind.RelativeOrAbsolute));
        }
开发者ID:iancooper,项目名称:AtomEventStore,代码行数:42,代码来源:AtomLink.cs

示例13: GetMessageStructure

 internal static ArrayList GetMessageStructure(string inputMsgFile, CommunicationManager.ReceiverType RxType, int mid, int sid, string protocol, string version)
 {
     XPathNavigator navigator = new XPathDocument(inputMsgFile).CreateNavigator();
     int num = 2;
     int num2 = 2;
     int num3 = 0;
     if (RxType == CommunicationManager.ReceiverType.SLC)
     {
         num3 = 1;
     }
     ArrayList list = new ArrayList();
     SLCMsgStructure structure = new SLCMsgStructure();
     int num4 = 0;
     XPathExpression expr = navigator.Compile(string.Concat(new object[] { "/protocols/protocol[@name='", protocol, "'][@version='", version, "']/input/message[@mid='", mid, "'][@subid = '", sid, "']/field" }));
     XPathNodeIterator iterator = navigator.Select(expr);
     if (iterator.Count == 0)
     {
         expr = navigator.Compile(string.Concat(new object[] { "/protocols/protocol[@name='", protocol, "'][@version='", version, "']/input/message[@mid='", mid, "'][@subid = '']/field" }));
         iterator = navigator.Select(expr);
     }
     try
     {
         int num5 = 0;
         int num6 = 0;
         while (iterator.MoveNext())
         {
             XPathNavigator navigator2 = iterator.Current.Clone();
             if (navigator2.GetAttribute("name", "").Contains("LOOP"))
             {
                 num5 = int.Parse(navigator2.GetAttribute("numloops", ""));
                 num6 = int.Parse(navigator2.GetAttribute("numlines", ""));
                 for (int i = 0; i < num5; i++)
                 {
                     for (int j = 0; j < num6; j++)
                     {
                         iterator.MoveNext();
                         navigator2 = iterator.Current.Clone();
                         structure.fieldNumber = iterator.CurrentPosition;
                         structure.fieldName = navigator2.GetAttribute("name", "");
                         structure.bytes = int.Parse(navigator2.GetAttribute("bytes", ""));
                         structure.datatype = navigator2.GetAttribute("datatype", "");
                         structure.units = navigator2.GetAttribute("units", "");
                         if (navigator2.GetAttribute("scale", "") == "")
                         {
                             structure.scale = 1.0;
                         }
                         else
                         {
                             structure.scale = double.Parse(navigator2.GetAttribute("scale", ""));
                         }
                         structure.startByte = (((num + num2) + num3) + 1) + num4;
                         structure.endByte = (structure.startByte + structure.bytes) - 1;
                         structure.defaultValue = navigator2.GetAttribute("default", "");
                         num4 += structure.bytes;
                         list.Add(structure);
                     }
                 }
             }
             else
             {
                 structure.fieldNumber = iterator.CurrentPosition;
                 structure.fieldName = navigator2.GetAttribute("name", "");
                 structure.bytes = int.Parse(navigator2.GetAttribute("bytes", ""));
                 structure.datatype = navigator2.GetAttribute("datatype", "");
                 structure.units = navigator2.GetAttribute("units", "");
                 if (navigator2.GetAttribute("scale", "") == "")
                 {
                     structure.scale = 1.0;
                 }
                 else
                 {
                     structure.scale = double.Parse(navigator2.GetAttribute("scale", ""));
                 }
                 structure.startByte = (((num + num2) + num3) + 1) + num4;
                 structure.endByte = (structure.startByte + structure.bytes) - 1;
                 structure.defaultValue = navigator2.GetAttribute("default", "");
                 num4 += structure.bytes;
                 list.Add(structure);
             }
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
     return list;
 }
开发者ID:facchinm,项目名称:SiRFLive,代码行数:87,代码来源:utils_AutoReply.cs

示例14: ProcessFile

 public override void ProcessFile(string file)
 {
     foreach (Exception ex in initializationErrors)
     {
         AddError(ex.Message);
     }
     using (XmlTextReader reader = new XmlTextReader(file))
     {
         var navigator = new XPathDocument(reader).CreateNavigator();
         foreach (XPathNavigator dvd in navigator.Select("/Collection/DVD|/DVD")) // Allow both collection file and single profile export
         {
             HandleDvd(dvd);
         }
     }
 }
开发者ID:peeboo,项目名称:open-media-library,代码行数:15,代码来源:DVDProfilerImporter.cs

示例15: Main

        // Methods
        public static int Main(string[] args)
        {
            XPathDocument document;

            ConsoleApplication.WriteBanner();

            OptionCollection options = new OptionCollection {
                new SwitchOption("?", "Show this help page."),
                new StringOption("config", "Specify a configuration file.", "versionCatalog"),
                new StringOption("out", "Specify an output file containing version information.", "outputFile"),
                new BooleanOption("rip", "Specify whether to rip old APIs which are not supported by the " +
                    "latest versions.")
            };

            ParseArgumentsResult result = options.ParseArguments(args);

            if(result.Options["?"].IsPresent)
            {
                Console.WriteLine("VersionBuilder [options]");
                options.WriteOptionSummary(Console.Out);
                return 0;
            }

            if(!result.Success)
            {
                result.WriteParseErrors(Console.Out);
                return 1;
            }

            if(result.UnusedArguments.Count != 0)
            {
                Console.WriteLine("No non-option arguments are supported.");
                return 1;
            }

            if(!result.Options["config"].IsPresent)
            {
                ConsoleApplication.WriteMessage(LogLevel.Error, "You must specify a version catalog file.");
                return 1;
            }

            bool rip = true;

            if(result.Options["rip"].IsPresent && !((bool)result.Options["rip"].Value))
                rip = false;

            string uri = (string)result.Options["config"].Value;

            try
            {
                document = new XPathDocument(uri);
            }
            catch(IOException ioEx)
            {
                ConsoleApplication.WriteMessage(LogLevel.Error, String.Format(CultureInfo.CurrentCulture,
                    "An error occurred while accessing the version catalog file '{0}'. The error message " +
                    "is: {1}", uri, ioEx.Message));
                return 1;
            }
            catch(XmlException xmlEx)
            {
                ConsoleApplication.WriteMessage(LogLevel.Error, String.Format(CultureInfo.CurrentCulture,
                    "The version catalog file '{0}' is not well-formed. The error message is: {1}", uri,
                    xmlEx.Message));
                return 1;
            }

            XPathNavigator navigator = document.CreateNavigator().SelectSingleNode("versions");
            XPathExpression expr = XPathExpression.Compile("string(ancestor::versions/@name)");
            List<VersionInfo> allVersions = new List<VersionInfo>();
            List<string> latestVersions = new List<string>();

            foreach(XPathNavigator navigator2 in document.CreateNavigator().Select("versions//version[@file]"))
            {
                string group = (string)navigator2.Evaluate(expr);
                string attribute = navigator2.GetAttribute("name", String.Empty);

                if(string.IsNullOrEmpty(attribute))
                    ConsoleApplication.WriteMessage(LogLevel.Error, "Every version element must have a name attribute.");

                string name = navigator2.GetAttribute("file", String.Empty);

                if(String.IsNullOrEmpty(attribute))
                    ConsoleApplication.WriteMessage(LogLevel.Error, "Every version element must have a file attribute.");

                string ripOldString = navigator2.GetAttribute("ripOldApis", String.Empty);
                bool ripOld = ripOldString == "1" || String.Equals("true", ripOldString, StringComparison.OrdinalIgnoreCase);

                name = Environment.ExpandEnvironmentVariables(name);
                VersionInfo item = new VersionInfo(attribute, group, name, ripOld);
                allVersions.Add(item);
            }

            string str5 = String.Empty;

            foreach(VersionInfo info2 in allVersions)
                if(!info2.RipOldApis && (!rip || info2.Group != str5))
                {
                    latestVersions.Add(info2.Name);
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:101,代码来源:VersionBuilderCore.cs


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