Example #1
0
        public List <LeafNodeDictionaryEntry> GetAndRemoveByTagNames(List <String> tags, Boolean DoRemove = true, Boolean Inverse = false)
        {
            List <String> ToRemove = new List <string>();
            List <LeafNodeDictionaryEntry> output = new List <LeafNodeDictionaryEntry>();
            List <Regex> regexList = new List <Regex>();

            //foreach (String tag in tags)
            //{
            //    Regex r = new Regex(tag + "\\[[\\d]+\\]\\Z");
            //    regexList.Add(r);
            //}

            foreach (var item in items.ToList())
            {
                String nodeName = XPathTools.GetLastNodeNameFromXPath(item.XPath).ToLower();

                if (tags.Contains(nodeName) == !Inverse)
                {
                    ToRemove.Add(item.XPath);
                    output.Add(item);
                }
                //Boolean isMatch = false;
                //foreach (var r in regexList)
                //{

                //    if (r.IsMatch(item.XPath))
                //    {
                //        isMatch = true;

                //        break;
                //    }
                //}
                //if (isMatch == !Inverse)
                //{

                //}
            }
            if (DoRemove)
            {
                RemoveEntriesByXPath(ToRemove);
                RebuildIndex();
            }

            return(output);
        }