Allow to construct a XML tree from a text buffer
This commit is contained in:
@@ -70,7 +70,7 @@ public:
|
||||
bool read(const std::string& fn) { set_filename(fn); return read_internal(false); }
|
||||
bool read_and_validate() { return read_internal(true); }
|
||||
bool read_and_validate(const std::string& fn) { set_filename(fn); return read_internal(true); }
|
||||
bool read_buffer(const std::string&);
|
||||
bool read_buffer(const std::string&, bool to_tree_doc = false);
|
||||
|
||||
bool write() const;
|
||||
bool write(const std::string& fn) { set_filename(fn); return write(); }
|
||||
|
||||
@@ -120,7 +120,7 @@ XMLTree::read_internal(bool validate)
|
||||
}
|
||||
|
||||
bool
|
||||
XMLTree::read_buffer(const string& buffer)
|
||||
XMLTree::read_buffer(const string& buffer, bool to_tree_doc)
|
||||
{
|
||||
xmlDocPtr doc;
|
||||
|
||||
@@ -135,7 +135,14 @@ XMLTree::read_buffer(const string& buffer)
|
||||
}
|
||||
|
||||
_root = readnode(xmlDocGetRootElement(doc));
|
||||
xmlFreeDoc(doc);
|
||||
if (to_tree_doc) {
|
||||
if (_doc) {
|
||||
xmlFreeDoc (_doc);
|
||||
}
|
||||
_doc = doc;
|
||||
} else {
|
||||
xmlFreeDoc (doc);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user