Exemplo n.º 1
0
        /// <summary>
        ///   Removes all Tags of the given type. Doesnt traverse the tree
        /// </summary>
        /// <param name="type"> Type of the tags that should be removed </param>
        /// <returns> true when tags were removed, false when no tags were found and removed </returns>
        public bool RemoveTags(Type type)
        {
            bool ret = false;

            ElementList list = SelectElements(type);

            if (list.Count > 0)
            {
                ret = true;
            }

            foreach (Element e in list)
            {
                e.Remove();
            }

            return ret;
        }
Exemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="e"> </param>
        /// <param name="tagname"> </param>
        /// <param name="es"> </param>
        /// <param name="traverseChildren"> </param>
        /// <returns> </returns>
        private ElementList _SelectElements(Element e, string tagname, ElementList es, bool traverseChildren)
        {
            if (e.ChildNodes.Count > 0)
            {
                foreach (Node n in e.ChildNodes)
                {
                    if (n.NodeType == NodeType.Element)
                    {
                        if (((Element) n).m_TagName == tagname)
                        {
                            es.Add(n);
                        }

                        if (traverseChildren)
                        {
                            _SelectElements((Element) n, tagname, es, true);
                        }
                    }
                }
            }

            return es;
        }
Exemplo n.º 3
0
        /// <summary>
        /// </summary>
        /// <param name="e"> </param>
        /// <param name="type"> </param>
        /// <param name="es"> </param>
        /// <param name="traverseChildren"> </param>
        /// <returns> </returns>
        private ElementList _SelectElements(Element e, Type type, ElementList es, bool traverseChildren)
        {
            if (e.ChildNodes.Count > 0)
            {
                foreach (Node n in e.ChildNodes)
                {
                    if (n.NodeType == NodeType.Element)
                    {
                        if (n.GetType() == type)
                        {
                            es.Add(n);
                        }

                        if (traverseChildren)
                        {
                            _SelectElements((Element) n, type, es, true);
                        }
                    }
                }
            }

            return es;
        }
Exemplo n.º 4
0
 /// <summary>
 ///   returns a nodelist of all found nodes of the given Type
 /// </summary>
 /// <param name="e"> </param>
 /// <param name="type"> </param>
 /// <param name="es"> </param>
 /// <returns> </returns>
 private ElementList _SelectElements(Element e, Type type, ElementList es)
 {
     return _SelectElements(e, type, es, false);
 }
Exemplo n.º 5
0
 /// <summary>
 /// </summary>
 /// <param name="type"> </param>
 /// <returns> </returns>
 public ElementList SelectElements(Type type)
 {
     var es = new ElementList();
     return _SelectElements(this, type, es);
 }