예제 #1
0
                // find the next sibling with the given tag and/or attribute/value pair
                //data_node *find_next_matching_sibling(const char *name, const char *attribute, const char *matchval);
                //data_node const *find_next_matching_sibling(const char *name, const char *attribute, const char *matchval) const;

                // add a new child node
                public data_node add_child(string name, string value)
                {
                    if (string.IsNullOrEmpty(name))  //if (!name || !*name)
                    {
                        return(null);
                    }

                    // new element: create a new node
                    data_node node;

                    node = new data_node(this, name, value);

                    if (node.get_name() == null || (node.get_value() == null && value != null))
                    {
                        //delete node;
                        return(null);
                    }

                    // add us to the end of the list of siblings
                    data_node pnode;

                    if (m_first_child == null)
                    {
                        m_first_child = node;
                    }
                    else
                    {
                        for (pnode = m_first_child; pnode.m_next != null; pnode = pnode.m_next)
                        {
                        }

                        pnode.m_next = node;
                    }

                    return(node);
                }