diff --git a/Cantera/src/base/xml.cpp b/Cantera/src/base/xml.cpp index 02b83c335..5c6396fbc 100755 --- a/Cantera/src/base/xml.cpp +++ b/Cantera/src/base/xml.cpp @@ -482,6 +482,27 @@ namespace Cantera { } } + void XML_Node::clear() { + int n = static_cast(m_children.size()); + for (int i = 0; i < n; i++) { + if (m_children[i]) { + if (m_children[i]->parent() == this) { + delete m_children[i]; + m_children[i] = 0; + } + } + } + m_value.clear(); + m_childindex.clear(); + m_attribs.clear(); + m_children.clear(); + + m_nchildren = 0; + m_iscomment = false; + m_linenum = 0; + + } + // Add a child node to the current node containing a comment /* * Child node will have the name, "comment". diff --git a/Cantera/src/base/xml.h b/Cantera/src/base/xml.h index 4f48c5505..db4d6ed51 100755 --- a/Cantera/src/base/xml.h +++ b/Cantera/src/base/xml.h @@ -380,6 +380,13 @@ namespace Cantera { */ std::string attrib(const std::string & attr) const; + //! Clear the current node and everything under it + /*! + * The value, attributes and children are all zeroed. The name and the + * parent information is kept. + */ + void clear(); + private: //! Returns a changeable value of the attributes map for the current node /*! @@ -644,7 +651,7 @@ namespace Cantera { //! into the destination XML_Node tree, doing a complete copy //! as we go. /*! - * Note this is a const function becuase the current XML_Node and + * Note this is a const function because the current XML_Node and * its children isn't altered by this operation. * * @param node_dest This is the XML node to receive the information