diff --git a/libs/pbd/pbd/xml++.h b/libs/pbd/pbd/xml++.h index d17f77bd3c..31059db418 100644 --- a/libs/pbd/pbd/xml++.h +++ b/libs/pbd/pbd/xml++.h @@ -130,6 +130,8 @@ public: const std::string& set_content(const std::string&); XMLNode* add_content(const std::string& s = std::string()); + const std::string& child_content() const; + const XMLNodeList& children(const std::string& str = std::string()) const; XMLNode* child(const char*) const; XMLNode* add_child(const char *); diff --git a/libs/pbd/xml++.cc b/libs/pbd/xml++.cc index ece30bef1d..f222d32b3e 100644 --- a/libs/pbd/xml++.cc +++ b/libs/pbd/xml++.cc @@ -381,6 +381,26 @@ XMLNode::set_content(const string& c) return _content; } +/* Return the content of the first content child + * + * `Foo`. + * the `node` is not a content node, but has a child-node `text`. + * + * This method effectively is identical to + * return this->child("text")->content() + */ +const string& +XMLNode::child_content() const +{ + static const string empty = ""; + for (XMLNodeList::const_iterator n = children ().begin (); n != children ().end (); ++n) { + if ((*n)->is_content ()) { + return (*n)->content (); + } + } + return empty; +} + XMLNode* XMLNode::child (const char* name) const {