//void write_recursive(int indent, util::core_file &file) const; data_node get_sibling(string name) { /* loop over siblings and find a matching name */ for (data_node node = this; node != null; node = node.get_next_sibling()) { if (strcmp(node.get_name(), name) == 0) { return(node); } } return(null); }
// 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); }