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


C# XPathNavigator.SelectSingleNode方法代码示例

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


在下文中一共展示了XPathNavigator.SelectSingleNode方法的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: Emit

        public override void Emit(XPathNavigator patternNavigator)
        {
            string name = patternNavigator.SelectSingleNode("@Name").Value;
            string constraintMode = patternNavigator.SelectSingleNode("@ConstraintMode").Value;

            DTS.Sequence newParentContainer = VulcanPackage.AddSequenceContainer(name, ParentContainer);

            DTS.Executable previousExec = null;
            Pattern p = null;
            foreach (XPathNavigator nav in patternNavigator.SelectChildren(XPathNodeType.Element))
            {
                p = PatternFactory.ProcessPattern(VulcanPackage,newParentContainer, nav,p);

                switch (constraintMode)
                {
                    case "Linear":
                        VulcanPackage.AddPrecedenceConstraint(previousExec, p.FirstExecutableGeneratedByPattern, newParentContainer);
                        break;
                    case "Parallel":
                        break;
                    default:
                        Message.Trace(Severity.Error, "Unknown ConstraintMode {0}", constraintMode);
                        break;
                }
                previousExec = p.LastExecutableGeneratedByPattern;
            }
            this.FirstExecutableGeneratedByPattern = newParentContainer;
            this.LastExecutableGeneratedByPattern = this.FirstExecutableGeneratedByPattern;
        }
开发者ID:japj,项目名称:vulcan,代码行数:29,代码来源:ContainerPattern.cs

示例3: ParseResponseProperties

        /// <summary>
        /// Parses the various properties from the XML document and populates the given SearchResult.
        /// </summary>
        /// <param name="result">The Google.CustomSearch.SearchResult to populate.</param>
        /// <param name="nav">The XPathNavigator for the response document.</param>
        private void ParseResponseProperties(SearchResult result, XPathNavigator nav)
        {
            XPathNavigator timeNode = nav.SelectSingleNode("/GSP/TM");
            if (timeNode != null)
                result.Time = timeNode.Value;

            XPathNavigator titleNode = nav.SelectSingleNode("/GSP/Context/title");
            if (titleNode != null)
                result.Title = titleNode.Value;

            XPathNavigator resultContainer = nav.SelectSingleNode("/GSP/RES");
            if (resultContainer != null)
            {
                // See http://www.google.com/cse/docs/resultsxml.html#results_xml_tag_XT
                result.Exact = resultContainer.SelectSingleNode("XT") != null;

                result.Filtered = resultContainer.SelectSingleNode("FI") != null;

                int startIndex;
                string start = resultContainer.GetAttribute("SN", string.Empty);
                if (int.TryParse(start, out startIndex))
                {
                    result.StartIndex = startIndex;
                }

                int endIndex;
                string end = resultContainer.GetAttribute("EN", string.Empty);
                if (int.TryParse(end, out endIndex))
                {
                    result.EndIndex = endIndex;
                }

                // Next and previous URLs
                XPathNavigator navigation = resultContainer.SelectSingleNode("NB");
                if (null != navigation)
                {
                    XPathNavigator nextLink = navigation.SelectSingleNode("NU");
                    if (null != nextLink)
                        result.NextPageLink = nextLink.Value;

                    XPathNavigator previousLink = navigation.SelectSingleNode("NP");
                    if (null != previousLink)
                        result.PreviousPageLink = previousLink.Value;
                }

                XPathNavigator totalNode = resultContainer.SelectSingleNode("M");
                if (totalNode != null)
                {
                    int total;
                    if (int.TryParse(totalNode.Value, out total))
                    {
                        result.Total = total;
                    }
                }
            }

            this.ParseSpellings(result, nav);

            this.ParseFacets(result, nav);
        }
开发者ID:musakkhir,项目名称:cse-net,代码行数:65,代码来源:ResponseParser.cs

示例4: Emit

        public override void Emit(XPathNavigator patternNavigator)
        {
            if (patternNavigator != null)
            {
                string name = patternNavigator.SelectSingleNode("@Name").Value;
                string sourcePath = patternNavigator.SelectSingleNode("@SourcePath").Value;
                string destPath = patternNavigator.SelectSingleNode("@DestinationPath").Value;
                string operationAsString = patternNavigator.SelectSingleNode("@Operation").Value;

                DTSTasks.FileSystemTask.DTSFileSystemOperation operation = DTSTasks.FileSystemTask.DTSFileSystemOperation.CopyDirectory;
                switch (operationAsString.ToUpperInvariant())
                {
                    case "COPYDIRECTORY":
                        operation = DTSTasks.FileSystemTask.DTSFileSystemOperation.CopyDirectory;
                        break;
                    default:
                        break;
                }

                FileSystemTask ft = new FileSystemTask(VulcanPackage, name, name, ParentContainer, sourcePath, destPath, operation);
                ft.SetExpression("OverwriteDestinationFile", "True");

                this.FirstExecutableGeneratedByPattern = ft.TaskHost;
                this.LastExecutableGeneratedByPattern = ft.TaskHost;
            }
        }
开发者ID:japj,项目名称:vulcan,代码行数:26,代码来源:FileSystemTaskPattern.cs

示例5: Initialize

        //=====================================================================

        /// <inheritdoc />
        public override void Initialize(XPathNavigator configuration)
        {
            // Get the condition
            XPathNavigator if_node = configuration.SelectSingleNode("if");

            if(if_node == null)
                throw new ConfigurationErrorsException("You must specify a condition using the <if> element.");

            string condition_xpath = if_node.GetAttribute("condition", String.Empty);

            if(String.IsNullOrEmpty(condition_xpath))
                throw new ConfigurationErrorsException("You must define a condition attribute on the <if> element");

            condition = XPathExpression.Compile(condition_xpath);

            // Construct the true branch
            XPathNavigator then_node = configuration.SelectSingleNode("then");

            if(then_node != null)
                true_branch = BuildAssembler.LoadComponents(then_node);

            // Construct the false branch
            XPathNavigator else_node = configuration.SelectSingleNode("else");

            if(else_node != null)
                false_branch = BuildAssembler.LoadComponents(else_node);

            // Keep a pointer to the context for future use
            context = this.BuildAssembler.Context;
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:33,代码来源:IfThenComponent.cs

示例6: ObsRequestNode

 public ObsRequestNode(XPathNavigator nav)
 {
     ID = nav.SelectSingleNode ("@id").Value;
     Description = nav.SelectSingleNode ("description").Value;
     State = new RequestState (nav.SelectSingleNode ("state"));
     Action = new RequestAction (nav.SelectSingleNode ("action"));
 }
开发者ID:abock,项目名称:obs-tree-analyzer,代码行数:7,代码来源:ObsRequestNode.cs

示例7: Emit

        public override void Emit(XPathNavigator patternNavigator)
        {
            if (patternNavigator != null)
            {
                string name = patternNavigator.SelectSingleNode("@Name").Value;

                string fileName =
                    Resources.Create+
                    name +
                    Resources.ExtensionSQLFile;

                string filePath = VulcanPackage.AddFileToProject(fileName);

                TableHelper th = new TableHelper(name, VulcanPackage.VulcanConfig, patternNavigator.SelectSingleNode("rc:Table",VulcanPackage.VulcanConfig.NamespaceManager));
                th.TraceHelper();

                th.TraceHelper();

                TableEmitterEx tex = new TableEmitterEx(th, VulcanPackage);

                tex.Emit(filePath,false);
                Connection connection = Connection.GetExistingConnection(VulcanPackage, patternNavigator);
                SQLTask sqlTask = new SQLTask(VulcanPackage,
                    Resources.Create + name,
                    Resources.Create + name,
                    ParentContainer,
                    connection
                    );

                sqlTask.TransmuteToFileTask(fileName);
                this.FirstExecutableGeneratedByPattern = sqlTask.SQLTaskHost;
                this.LastExecutableGeneratedByPattern = this.FirstExecutableGeneratedByPattern;
            }
        }
开发者ID:japj,项目名称:vulcan,代码行数:34,代码来源:FactTablePattern.cs

示例8: Argument

        internal Argument(XPathNavigator navigator, string nspace)
        {
            XmlNamespaceManager nsmanager = new XmlNamespaceManager(navigator.NameTable);
            nsmanager.AddNamespace("u", nspace);

            name = navigator.SelectSingleNode("u:name", nsmanager).Value;
            name = name.Trim();
            related = navigator.SelectSingleNode("u:relatedStateVariable", nsmanager).Value;
            related = related.Trim();
        }
开发者ID:MatthewMiddleweek,项目名称:ohNet,代码行数:10,代码来源:UpnpServiceXml.cs

示例9: ParseXml

        /// <summary>
        /// Populates the class members with data from the specified 
        /// active person information XML.
        /// </summary>
        /// 
        /// <param name="navigator">
        /// The XML to get the active person information from.
        /// </param>
        /// 
        internal override void ParseXml(XPathNavigator navigator)
        {
            base.ParseXml(navigator);

            Email = navigator.SelectSingleNode("contact-email").Value;

            RecordAuthorizationState = AuthorizedRecordState.Active;

            _name = navigator.SelectSingleNode("name").Value;
        }
开发者ID:marteaga,项目名称:healthvault-azurestorage,代码行数:19,代码来源:ActiveRecordAuthorization.cs

示例10: Emit

        public override void Emit(XPathNavigator patternNavigator)
        {
            if (patternNavigator != null)
            {
                string firstOrLast = patternNavigator.SelectSingleNode("@FirstOrLast").Value;
                string status = patternNavigator.SelectSingleNode("@Status").Value;
                string notes = patternNavigator.SelectSingleNode("@Notes").Value;

                Connection tableConnection =
                    Connection.GetExistingConnection(VulcanPackage, LogtainerPattern.CurrentLog.TableConnectionName);

                string execSqlTaskName = LogtainerPattern.CurrentLog.LogName + Resources.Seperator + firstOrLast + Guid.NewGuid();
                TemplateEmitter te = new TemplateEmitter(VulcanPackage.TemplateManager["LogSelectQuery"]);
                if (
                    LogtainerPattern.CurrentLog.SourceColumn == null ||
                    LogtainerPattern.CurrentLog.DestinationColumn == null ||
                    LogtainerPattern.CurrentLog.TableConnectionName == null ||
                    LogtainerPattern.CurrentLog.Table == null)
                {
                    Message.Trace(Severity.Error,
                        "Could not perform LogUpdate (On Log: {0}), Parent Logtainer does not contain all of the necessary information.  Needs SourceColumn, DestinationColumn, TableConnectionName, and Table attributes.",LogtainerPattern.CurrentLog.LogName);
                    return;
                }

                te.SetNamedParameter("Source", LogtainerPattern.CurrentLog.SourceColumn);
                te.SetNamedParameter("Destination", LogtainerPattern.CurrentLog.DestinationColumn);
                te.SetNamedParameter("Table", LogtainerPattern.CurrentLog.Table);
                te.SetNamedParameter("Status", status);
                te.SetNamedParameter("Notes", notes);
                te.SetNamedParameter("SourceConvertStyle", "21");
                te.SetNamedParameter("DestinationConvertStyle", "21");

                string query;
                te.Emit(out query);

                SQLTask readForLogTask = new SQLTask(VulcanPackage, execSqlTaskName, execSqlTaskName, ParentContainer, tableConnection);
                readForLogTask.TransmuteToExpressionTask(String.Format("\"{0}\"", query));
                readForLogTask.ExecuteSQLTask.ResultSetType = Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ResultSetType.ResultSetType_SingleRow;

                DTS.Variable sourceVar = LogtainerPattern.CurrentLog[firstOrLast+"SourceRecord"];
                DTS.Variable destVar = LogtainerPattern.CurrentLog[firstOrLast+"DestinationRecord"];
                DTS.Variable statusVar = LogtainerPattern.CurrentLog["Status"];
                DTS.Variable notesVar = LogtainerPattern.CurrentLog["Notes"];

                readForLogTask.BindResult("0", sourceVar.QualifiedName);
                readForLogTask.BindResult("1", destVar.QualifiedName);
                readForLogTask.BindResult("2", statusVar.QualifiedName);
                readForLogTask.BindResult("3", notesVar.QualifiedName);

                this.FirstExecutableGeneratedByPattern = readForLogTask.SQLTaskHost;
                this.LastExecutableGeneratedByPattern = this.FirstExecutableGeneratedByPattern;
            }
        }
开发者ID:japj,项目名称:vulcan,代码行数:53,代码来源:LogUpdatePattern.cs

示例11: CreateNode

 private ReferenceNode CreateNode(XPathNavigator nav)
 {
     var hintPathNode = nav.SelectSingleNode("n:HintPath", ns);
     var isPrivateNode = nav.SelectSingleNode("n:Private", ns);
     var name = GetSimpleReferenceName(nav.GetAttribute("Include", ""));
     return new ReferenceNode
                {
                    Include = name,
                    HintPath = hintPathNode == null ? string.Empty : hintPathNode.Value,
                    IsPrivate = isPrivateNode == null ? GetDefaultPrivateValue(name) : bool.Parse(isPrivateNode.Value)
                };
 }
开发者ID:xiaoyvr,项目名称:yam,代码行数:12,代码来源:ProjectExtractor.cs

示例12: Load

        /// <summary>
        /// Initializes the syndication extension context using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <b>XPathNavigator</b> used to load this <see cref="SDataExtensionContext"/>.</param>
        /// <param name="manager">The <see cref="XmlNamespaceManager"/> object used to resolve prefixed syndication extension elements and attributes.</param>
        /// <returns><b>true</b> if the <see cref="SDataExtensionContext"/> was able to be initialized using the supplied <paramref name="source"/>; otherwise <b>false</b>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source, XmlNamespaceManager manager)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            var wasLoaded = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");
            Guard.ArgumentNotNull(manager, "manager");

            //------------------------------------------------------------
            //	Attempt to extract syndication extension information
            //------------------------------------------------------------
            if (source.HasChildren)
            {
                var syncModeNavigator = source.SelectSingleNode("sync:syncMode", manager);
                if (syncModeNavigator != null && !string.IsNullOrEmpty(syncModeNavigator.Value))
                {
                    SyncMode = (SyncMode) Enum.Parse(typeof (SyncMode), syncModeNavigator.Value, true);
                    wasLoaded = true;
                }

                var digestNavigator = source.SelectSingleNode("sync:digest", manager);
                if (digestNavigator != null)
                {
                    var digest = new Digest();
                    if (digest.Load(digestNavigator, manager))
                    {
                        Digest = digest;
                        wasLoaded = true;
                    }
                }

                var syncStateNavigator = source.SelectSingleNode("sync:syncState", manager);
                if (syncStateNavigator != null)
                {
                    var syncState = new SyncState();
                    if (syncState.Load(syncStateNavigator, manager))
                    {
                        SyncState = syncState;
                        wasLoaded = true;
                    }
                }
            }

            return wasLoaded;
        }
开发者ID:kodefuguru,项目名称:SDataCSharpClientLib,代码行数:58,代码来源:SDataSyncExtensionContext.cs

示例13: ZoneGroup

        public ZoneGroup(Discover disc, XPathNavigator node)
        {
            _coordinator = node.SelectSingleNode("@Coordinator").Value;
            _id = node.SelectSingleNode("@ID").Value;

            foreach (XPathNavigator nav in node.Select("ZoneGroupMember"))
            {
                ZonePlayer zp = disc.Intern(String.Concat("uuid:", nav.SelectSingleNode("@UUID").Value));
                _members.Add(zp);
            }

            _coordinatorZone = disc.Intern(String.Concat("uuid:", _coordinator));
            _members.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(_members_CollectionChanged);
        }
开发者ID:NathanHowell,项目名称:Sonority,代码行数:14,代码来源:ZoneGroup.cs

示例14: GetNodeValue

        public static string GetNodeValue(XPathNavigator node, string query)
        {
            if (node == null) return "N/A";

            var rtnNode = node.SelectSingleNode(query);
            return rtnNode == null ? "N/A" : rtnNode.Value.Trim();
        }
开发者ID:danieleli,项目名称:Swagger.Net,代码行数:7,代码来源:Utils.cs

示例15: CreateDerivedColumnsFromXml

        public static DerivedColumns CreateDerivedColumnsFromXml(Packages.VulcanPackage vulcanPackage, IDTSComponentMetaData90 parentComponent, MainPipe dataFlowTask, XPathNavigator derivedNav)
        {
            if (derivedNav == null || derivedNav.Name.ToUpperInvariant() != "DerivedColumns".ToUpperInvariant())
            {
                //We don't handle this.
                return null;
            }

            string componentName = derivedNav.SelectSingleNode("@Name", vulcanPackage.VulcanConfig.NamespaceManager).Value;
            Message.Trace(Severity.Debug, "Begin: DerivedColumns Transformation {0}", componentName);

            DerivedColumns dc = new DerivedColumns(vulcanPackage, dataFlowTask, parentComponent, componentName, componentName);

            foreach (XPathNavigator nav in derivedNav.Select("rc:Column", vulcanPackage.VulcanConfig.NamespaceManager))
            {
                string colName = nav.SelectSingleNode("@Name").Value;
                string typeAsString = nav.SelectSingleNode("@Type").Value;
                int length = nav.SelectSingleNode("@Length").ValueAsInt;
                int precision = nav.SelectSingleNode("@Precision").ValueAsInt;
                int scale = nav.SelectSingleNode("@Scale").ValueAsInt;
                int codepage = nav.SelectSingleNode("@Codepage").ValueAsInt;

                string expression = nav.Value;

                DataType type = TransformationFactory.GetDataTypeFromString(typeAsString);

                dc.AddOutputColumn(colName, type, expression, length, precision, scale, codepage);
            }
            return dc;
        }
开发者ID:japj,项目名称:vulcan,代码行数:30,代码来源:TransformationFactory.cs


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