Beispiel #1
0
        /// <summary>
        /// Finds the childless tags.
        /// </summary>
        /// <param name="tagName">Name of the tag.</param>
        /// <param name="caseSensitive">if set to <c>true</c> [case sensitive].</param>
        /// <returns></returns>
        public IList <string> FindChildlessTags(string tagName, bool caseSensitive)
        {
            IList <string> ret           = new List <string>();
            string         searchSubject = caseSensitive ? RawStream : RawStreamLowercase;

            if (!caseSensitive)
            {
                tagName = tagName.ToLower();
            }
            if (!tagName.StartsWith("<"))
            {
                tagName = "<" + tagName;
            }
            if (searchSubject != null)
            {
                int startpos = 0;
                while (true)
                {
                    int startIndex = searchSubject.IndexOf(tagName, startpos);
                    if (startIndex == -1)
                    {
                        break;
                    }
                    int endIndex = searchSubject.IndexOf(">", startIndex);
                    if (endIndex == -1)
                    {
                        break;
                    }

                    ret.Add(RawStream.Substring(startIndex, endIndex - startIndex + 1));

                    startpos = endIndex + 1;
                }
            }
            return(ret);
        }