Example #1
0
        public static SimpleXmlNodeList GetAllDescendents(XmlNode root)
        {
            SimpleXmlNodeList bfsQueue = new SimpleXmlNodeList();

            bfsQueue.Add(root);
            for (int i = 0; i < bfsQueue.Count; i++)
            {
                XmlNode node = bfsQueue[i];
                for (XmlNode child = node.FirstChild; child != null; child = child.NextSibling)
                {
                    bfsQueue.Add(child);
                }

                AddAttributes(bfsQueue, node, false);
            }

            return(bfsQueue);
        }
Example #2
0
        private static void AddAttributes(SimpleXmlNodeList list, XmlNode node, bool onlyNamespaces)
        {
            XmlAttributeCollection attributes = node.Attributes;

            if (attributes != null)
            {
                for (int i = 0; i < attributes.Count; i++)
                {
                    XmlAttribute a = attributes[i];
                    if (!onlyNamespaces || IsNamespaceNode(a))
                    {
                        list.Add(a);
                    }
                }
            }
        }