33#include "BESXMLUtils.h"
41#define MODULE "xmlutils"
42#define prolog string("BESXMLUtils::").append(__func__).append("() - ")
57 va_start( args, msg );
59 vsnprintf(mymsg,
sizeof mymsg, msg, args);
61 vector<string> *myerrors = (vector<string> *) context;
62 myerrors->push_back(mymsg);
80 if (node->properties ==
nullptr) {
84 xmlAttr *curr_prop = node->properties;
86 string prop_name = (
char *) curr_prop->name;
89 xmlNode *curr_val = curr_prop->children;
90 if (curr_val && curr_val->content) {
94 props[prop_name] = prop_val;
96 curr_prop = curr_prop->next;
112 name = (
char *) node->name;
115 xmlNode *child_node = node->children;
117 while (child_node && !done) {
118 if (child_node->type == XML_TEXT_NODE) {
119 if (child_node->content) {
120 BESDEBUG(MODULE, prolog <<
"child_node->content: " << child_node->content << std::endl);
123 BESDEBUG(MODULE, prolog <<
"value: " << value << std::endl);
130 child_node = child_node->next;
145 xmlNode *child_node =
nullptr;
147 child_node = node->children;
149 while (child_node && !done) {
150 if (child_node->type == XML_ELEMENT_NODE) {
155 child_node = child_node->next;
173 child_node = child_node->next;
175 while (child_node && !done) {
176 if (child_node->type == XML_ELEMENT_NODE) {
181 child_node = child_node->next;
196BESXMLUtils::GetChild(xmlNode *node,
const string &child_name,
string &child_value, map<string, string> &child_props)
198 xmlNode *child_node =
nullptr;
200 child_node = node->children;
202 while (child_node && !done) {
203 if (child_node->type == XML_ELEMENT_NODE) {
204 string name = (
char *) child_node->name;
206 if (name == child_name) {
211 child_node = child_node->next;
215 child_node = child_node->next;
static std::string xml2id(std::string in)
static void removeLeadingAndTrailingBlanks(std::string &key)
static void GetNodeInfo(xmlNode *node, std::string &name, std::string &value, std::map< std::string, std::string > &props)
get the name, value if any, and any properties for the specified node
static void GetProps(xmlNode *node, std::map< std::string, std::string > &props)
given an xml node, build the map of properties (xml attributes) for that node
static xmlNode * GetFirstChild(xmlNode *node, std::string &child_name, std::string &child_value, std::map< std::string, std::string > &child_props)
get the first element child node for the given node
static xmlNode * GetChild(xmlNode *node, const std::string &child_name, std::string &child_value, std::map< std::string, std::string > &child_props)
get the element child node of the given node with the given name
static xmlNode * GetNextChild(xmlNode *child_node, std::string &next_name, std::string &next_value, std::map< std::string, std::string > &next_props)
get the next element child node after the given child node
static void XMLErrorFunc(void *context, const char *msg,...)
error function used by libxml2 to report errors