コード例 #1
0
        /// <summary>
        /// Gets the nodes with xml path.
        /// </summary>
        /// <example>example: xxx.NodesPath("A.B.C")</example>
        /// <param name="xmlPath">The XML path.</param>
        /// <returns>List of FluentXml.</returns>
        public List <FluentXml> NodesPath(string xmlPath)
        {
            if (this.IsNullOrWhiteSpace(xmlPath))
            {
                return(this.Nodes());
            }

            if (!xmlPath.Contains("."))
            {
                return(this.GetNodesWithIndex(xmlPath));
            }
            else
            {
                var propertyChain = xmlPath.Trim().Split('.');

                FluentXml result = this;

                for (int i = 0; i < propertyChain.Length - 1; i++)
                {
                    result = result.Node(propertyChain[i]);
                }

                return(result.GetNodesWithIndex(propertyChain[propertyChain.Length - 1]));
            }
        }