
#include<xml_misc_tools.h>


//  ADDITIONAL libxml++ functions


list<xmlpp::Element*> get_Element_children(const xmlpp::Node* father_node, string imposedName)
{
  xmlpp::Element* newElement;
  list<xmlpp::Element*> res;
  list<xmlpp::Node*> childrenNodes = father_node->get_children();
  while(childrenNodes.size())
  {
    if (newElement = dynamic_cast<xmlpp::Element*>(childrenNodes.front()))
      if( (newElement->get_name()==imposedName) || (imposedName=="") )
        res.push_back(newElement);
    childrenNodes.pop_front();
  }
  return res;
}


std::string get_text_content(const xmlpp::Node* father_node)
{
  xmlpp::TextNode* newTextNode;
  std::string res="";
  list<xmlpp::Node*> childrenNodes = father_node->get_children();
  while(childrenNodes.size())
  {
    if (newTextNode = dynamic_cast<xmlpp::TextNode*>(childrenNodes.front()))
      if(!newTextNode->is_white_space())
        res+=newTextNode->get_content();
    childrenNodes.pop_front();
  }
  return res;
}

void xml_print_list(list<xmlpp::Element*> & liszt)
{
  for(uint i=0;i<liszt.size();++i )
  {
    liszt.push_back( liszt.front() );
    cout<<liszt.front()->get_name()<<endl;
    liszt.pop_front();
  }
}


// ********* create a list<string> from a list of arguments.
// tremendous.


list<string> xml_names(string str1)
{list<string> ls; ls.push_back(str1); return ls;}

list<string> xml_names(string str1, string str2)
{list<string> ls=xml_names(str1); ls.push_back(str2); return ls;}

list<string> xml_names(string str1, string str2, string str3)
{list<string> ls=xml_names(str1,str2); ls.push_back(str3); return ls;}

list<string> xml_names(string str1, string str2, string str3, string str4)
{list<string> ls=xml_names(str1,str2,str3); ls.push_back(str4); return ls;}

list<string> xml_names(string str1, string str2, string str3, string str4, string str5)
{list<string> ls=xml_names(str1,str2,str3,str4); ls.push_back(str5); return ls;}

list<string> xml_names(string str1, string str2, string str3, string str4, string str5, string str6)
{list<string> ls=xml_names(str1,str2,str3,str4,str5); ls.push_back(str6); return ls;}


