void Opal::Presentity::rename_group (const std::string old_name, const std::string new_name) { bool old_name_present = false; bool already_in_new_name = false; std::set<xmlNodePtr> nodes_to_remove; /* remove the old name's node * and check if we aren't already in the new name's group */ for (xmlNodePtr child = node->children ; child != NULL ; child = child->next) { if (child->type == XML_ELEMENT_NODE && child->name != NULL) { if (xmlStrEqual (BAD_CAST ("group"), child->name)) { xmlChar* xml_str = xmlNodeGetContent (child); if (xml_str != NULL) { if (!xmlStrcasecmp ((const xmlChar*)old_name.c_str (), xml_str)) { nodes_to_remove.insert (child); // don't free what we loop on! old_name_present = true; } if (!xmlStrcasecmp ((const xmlChar*)new_name.c_str (), xml_str)) { already_in_new_name = true; } xmlFree (xml_str); } } } } // ok, now we can clean up! for (std::set<xmlNodePtr>::iterator iter = nodes_to_remove.begin (); iter != nodes_to_remove.end (); ++iter) { xmlUnlinkNode (*iter); xmlFreeNode (*iter); } if (old_name_present && !already_in_new_name) { xmlNewChild (node, NULL, BAD_CAST "group", BAD_CAST robust_xmlEscape (node->doc, new_name).c_str ()); } updated (); trigger_saving (); }
/* reads a CDF feed URL and returns a new channel structure (even if the feed could not be read) */ static void cdf_parse(feedParserCtxtPtr ctxt, xmlNodePtr cur) { CDFChannelPtr cp; cp = g_new0(struct CDFChannel, 1); do { /* note: we support only one flavour of CDF channels! We will only support the outer channel of the CDF feed. */ /* find outer channel tag */ while(cur) { if(cur->type == XML_ELEMENT_NODE && (!xmlStrcasecmp(cur->name, BAD_CAST"channel"))) { cur = cur->xmlChildrenNode; break; } cur = cur->next; } time(&(cp->time)); /* find first "real" channel tag */ while(cur) { if((!xmlStrcasecmp(cur->name, BAD_CAST"channel"))) { parseCDFChannel(ctxt, cur, cp); break; } cur = cur->next; } /* after parsing we fill in the infos into the subscription structure */ subscription_set_default_update_interval(ctxt->subscription, -1); g_free(cp); } while (FALSE); }
static gboolean gnome_da_xml_get_bool (const xmlNode *parent, const gchar *val_name) { xmlNode *element; gboolean ret_val = FALSE; xmlChar *xml_val_name; gint len; g_return_val_if_fail (parent != NULL, FALSE); g_return_val_if_fail (parent->children != NULL, ret_val); g_return_val_if_fail (val_name != NULL, FALSE); xml_val_name = xmlCharStrdup (val_name); len = xmlStrlen (xml_val_name); for (element = parent->children; element != NULL; element = element->next) { if (!xmlStrncmp (element->name, xml_val_name, len)) { xmlChar *cont = xmlNodeGetContent (element); if (!xmlStrcasecmp (cont, "true") || !xmlStrcasecmp (cont, "1")) ret_val = TRUE; else ret_val = FALSE; xmlFree (cont); } } xmlFree (xml_val_name); return ret_val; }
int Snes9xConfig::parse_calibration (xmlNodePtr node) { xmlAttrPtr attr; int joynum = -1; int num_joysticks = 0; int retval = 0; for (num_joysticks = 0; joystick[num_joysticks]; num_joysticks++) { } for (attr = node->properties; attr; attr = attr->next) { if (!xmlStrcasecmp (attr->name, BAD_CAST "joystick")) { joynum = atoi ((char *) attr->children->content); if (joynum < 0 || joynum >= num_joysticks) return 0; } } for (xmlNodePtr i = node->children; i; i = i->next) { if (!xmlStrcasecmp (i->name, BAD_CAST "axis")) { retval = parse_axis (i, joynum) | retval; } } return retval; }
int Snes9xConfig::parse_option (xmlNodePtr node) { xmlAttrPtr attr = NULL; char *name, *value; /* Find name string */ for (attr = node->properties; attr; attr = attr->next) { if (!xmlStrcasecmp (attr->name, BAD_CAST "name")) { name = (char *) attr->children->content; break; } } if (!attr) return 1; /* Find value string */ for (attr = node->properties; attr; attr = attr->next) { if (!xmlStrcasecmp (attr->name, BAD_CAST "value")) { value = (char *) attr->children->content; break; } } if (!attr) return 1; return set_option (name, value); }
/** * Looks up the xmltv user display name of a channel given its xmltv id. */ const char *xmltv_lookup_channel_name( xmltv_t *xmltv, const char *id ) { xmlNodePtr cur = xmltv->root->xmlChildrenNode; if( xmltv->display_chan ) xmlFree( xmltv->display_chan ); xmltv->display_chan = 0; while( cur ) { if( !xmlStrcasecmp( cur->name, BAD_CAST "channel" ) ) { xmlChar *curid = xmlGetProp( cur, BAD_CAST "id" ); if ( curid ) { if ( !xmlStrcasecmp( curid, BAD_CAST id ) ) { xmlNodePtr sub = cur->xmlChildrenNode; while( sub && xmlStrcasecmp( sub->name, BAD_CAST "display-name" ) ) { sub = sub->next; } if ( sub ) { xmltv->display_chan = xmlNodeGetContent( sub ); xmlFree( curid ); if( xmltv->is_tv_grab_na ) { return tv_grab_na_skip( (char *) xmltv->display_chan ); } else { return (char *) xmltv->display_chan; } } } xmlFree( curid ); } } cur = cur->next; } return 0; }
int parse_actor_shirt (actor_types *act, xmlNode *cfg) { xmlNode *item; char errmsg[120]; int ok, col_idx; shirt_part *shirt; if (cfg == NULL || cfg->children == NULL) return 0; col_idx = get_property (cfg, "color", "shirt color", shirt_color_dict); if (col_idx < 0) return 0; shirt = &(act->shirt[col_idx]); ok = 1; for (item = cfg->children; item; item = item->next) { if (item->type == XML_ELEMENT_NODE) { if (xmlStrcasecmp (item->name, "arms") == 0) { get_string_value (shirt->arms_name, sizeof (shirt->arms_name), item); } else if (xmlStrcasecmp (item->name, "model") == 0) { get_string_value (shirt->model_name, sizeof (shirt->model_name), item); } else if (xmlStrcasecmp (item->name, "torso") == 0) { get_string_value (shirt->torso_name, sizeof (shirt->torso_name), item); } else { snprintf (errmsg, sizeof (errmsg), "unknown shirt property \"%s\"", item->name); LogError (errmsg); ok = 0; } } } return ok; }
int Snes9xConfig::parse_snes9x (xmlNodePtr node) { xmlNodePtr i = NULL; int retval = 0; if (xmlStrcasecmp (node->name, BAD_CAST "snes9x")) { fprintf (stderr, _("failure to read snes9x node")); return 1; } for (i = node->children; i; i = i->next) { if (!xmlStrcasecmp (i->name, BAD_CAST "preferences")) { retval = parse_preferences (i) || retval; } else if (!xmlStrcasecmp (i->name, BAD_CAST "controls")) { retval = parse_controls (i) || retval; } } return 0; }
int parse_actor_boots (actor_types *act, xmlNode *cfg) { xmlNode *item; char errmsg[120]; int ok, col_idx; boots_part *boots; if (cfg == NULL || cfg->children == NULL) return 0; col_idx = get_property (cfg, "color", "boots color", boots_color_dict); if (col_idx < 0) return 0; boots = &(act->boots[col_idx]); ok = 1; for (item = cfg->children; item; item = item->next) { if (item->type == XML_ELEMENT_NODE) { if (xmlStrcasecmp (item->name, "skin") == 0) { get_string_value (boots->boots_name, sizeof (boots->boots_name), item); } else if (xmlStrcasecmp (item->name, "glow") == 0) { int mode = find_description_index (glow_mode_dict, item->children->content, "glow mode"); if (mode < 0) mode = GLOW_NONE; boots->glow = mode; } else { snprintf (errmsg, sizeof (errmsg), "unknown legs property \"%s\"", item->name); LogError (errmsg); ok = 0; } } } return ok; }
int parse_actor_body_part (body_part *part, xmlNode *cfg, const char *part_name) { xmlNode *item; char errmsg[120]; int ok = 1; if (cfg == NULL) return 0; for (item = cfg; item; item = item->next) { if (item->type == XML_ELEMENT_NODE) { if (xmlStrcasecmp (item->name, "model") == 0) { get_string_value (part->model_name, sizeof (part->model_name), item); } else if (xmlStrcasecmp (item->name, "skin") == 0) { get_string_value (part->skin_name, sizeof (part->skin_name), item); } else if (xmlStrcasecmp (item->name, "glow") == 0) { int mode = find_description_index (glow_mode_dict, item->children->content, "glow mode"); if (mode < 0) mode = GLOW_NONE; part->glow = mode; } else { snprintf (errmsg, sizeof (errmsg), "unknown %s property \"%s\"", part_name, item->name); LogError (errmsg); ok = 0; } } } return ok; }
int parse_actor_skin (actor_types *act, xmlNode *cfg) { xmlNode *item; char errmsg[120]; int ok, col_idx; skin_part *skin; if (cfg == NULL || cfg->children == NULL) return 0; col_idx = get_property (cfg, "color", "skin color", skin_color_dict); if (col_idx < 0) return 0; skin = &(act->skin[col_idx]); ok = 1; for (item = cfg->children; item; item = item->next) { if (item->type == XML_ELEMENT_NODE) { if (xmlStrcasecmp (item->name, "hands") == 0) { get_string_value (skin->hands_name, sizeof (skin->hands_name), item); } else if (xmlStrcasecmp (item->name, "head") == 0) { get_string_value (skin->head_name, sizeof (skin->head_name), item); } else { snprintf (errmsg, sizeof (errmsg), "unknown skin property \"%s\"", item->name); LogError (errmsg); ok = 0; } } } return ok; }
/** * Looks up the xmltv id of a channel given a corresponding xmltv display name. */ const char *xmltv_lookup_channel( xmltv_t *xmltv, const char *name ) { xmlNodePtr cur = xmltv->root->xmlChildrenNode; if( xmltv->curchan ) xmlFree( xmltv->curchan ); xmltv->curchan = 0; while( cur ) { if( !xmlStrcasecmp( cur->name, BAD_CAST "channel" ) ) { xmlNodePtr sub = cur->xmlChildrenNode; while( sub ) { if( !xmlStrcasecmp( sub->name, BAD_CAST "display-name" ) ) { xmlChar *curname = xmlNodeGetContent( sub ); if( curname ) { if( !xmlStrcasecmp( curname, BAD_CAST name ) ) { xmltv->curchan = xmlGetProp( cur, BAD_CAST "id" ); xmlFree( curname ); return (char *) xmltv->curchan; } xmlFree( curname ); } } sub = sub->next; } } cur = cur->next; } return 0; }
int Snes9xConfig::parse_joypad (xmlNodePtr node) { xmlAttrPtr attr; int joypad_number = -1; int retval = 0; /* Try to read joypad number */ for (attr = node->properties; attr; attr = attr->next) { if (!xmlStrcasecmp (attr->name, BAD_CAST "number")) { joypad_number = atoi ((char *) attr->children->content); if (joypad_number < 0 || joypad_number > (NUM_JOYPADS - 1)) return 1; } } for (xmlNodePtr i = node->children; i; i = i->next) { if (!xmlStrcasecmp (i->name, BAD_CAST "binding")) { retval = parse_binding (i, joypad_number) || retval; } } return retval; }
void ParseSimage(xmlAttr *a_node) { xmlAttr *cur_attr=NULL; for (cur_attr = a_node; cur_attr; cur_attr = cur_attr->next) { if (cur_attr->type==XML_ATTRIBUTE_NODE){ //name="" if(!xmlStrcasecmp(cur_attr->name,(xmlChar*)"name")){ #ifdef NEW_TEXTURES id = load_texture_cached((char*)cur_attr->children->content, tt_gui); #else /* NEW_TEXTURES */ id=load_texture_cache_deferred((char*)cur_attr->children->content,0); #endif /* NEW_TEXTURES */ } //isize="" if(!xmlStrcasecmp(cur_attr->name,(xmlChar*)"isize")){ isize=atoi((char*)cur_attr->children->content); } //tsize="" if(!xmlStrcasecmp(cur_attr->name,(xmlChar*)"tsize")){ tsize=atoi((char*)cur_attr->children->content); } //tid="" if(!xmlStrcasecmp(cur_attr->name,(xmlChar*)"tid")){ tid=atoi((char*)cur_attr->children->content); } //size="" if(!xmlStrcasecmp(cur_attr->name,(xmlChar*)"size")){ ssize=atoi((char*)cur_attr->children->content); } //x="" if(!xmlStrcasecmp(cur_attr->name,(xmlChar*)"x")){ x=atoi((char*)cur_attr->children->content); } //y="" if(!xmlStrcasecmp(cur_attr->name,(xmlChar*)"y")){ y=atoi((char*)cur_attr->children->content); } //mouseover="" if(!xmlStrcasecmp(cur_attr->name,(xmlChar*)"mouseover")){ mouseover=atoi((char*)cur_attr->children->content); } //xposupdate="" if(!xmlStrcasecmp(cur_attr->name,(xmlChar*)"xposupdate")){ xposupdate=atoi((char*)cur_attr->children->content); } //yposupdate="" if(!xmlStrcasecmp(cur_attr->name,(xmlChar*)"yposupdate")){ yposupdate=atoi((char*)cur_attr->children->content); } } } }
int bla_same_dialog(unsigned char* n_callid, unsigned char* n_fromtag, unsigned char* n_totag, unsigned char* o_callid, unsigned char* o_fromtag, unsigned char* o_totag) { if(n_callid && o_callid && xmlStrcasecmp(n_callid, o_callid)) return 0; if(n_fromtag && o_fromtag && xmlStrcasecmp(n_fromtag, o_fromtag)) return 0; if(n_totag && o_totag && xmlStrcasecmp(n_totag, o_totag)) return 0; return 1; }
static gboolean xmlstr_to_gboolean(xmlChar* str) { if (xmlStrcasecmp(str, BAD_CAST "true") == 0 || xmlStrcasecmp(str, BAD_CAST "on") == 0 || xmlStrcasecmp(str, BAD_CAST "yes") == 0) { return TRUE; } return FALSE; }
int Snes9xConfig::parse_binding (xmlNodePtr node, int joypad_number) { char *name = NULL; char *type = NULL; Binding b; for (xmlAttrPtr attr = node->properties; attr; attr = attr->next) { if (!xmlStrcasecmp (attr->name, BAD_CAST "name")) name = (char *) attr->children->content; else if (!xmlStrcasecmp (attr->name, BAD_CAST "binding")) type = (char *) attr->children->content; } b = Binding ((unsigned int) strtoul (type, NULL, 10)); if (joypad_number > -1 && joypad_number < NUM_JOYPAD_LINKS) { for (int i = 0; i < NUM_JOYPAD_LINKS; i++) { if (!strcasecmp (b_links[i].snes9x_name, name)) { Binding *buttons = (Binding *) &pad[joypad_number]; if (b.is_key () || b.is_joy ()) buttons[i] = b; else buttons[i].clear (); } } } else { for (int i = NUM_JOYPAD_LINKS; b_links[i].snes9x_name; i++) { if (!strcasecmp (b_links[i].snes9x_name, name)) { if (b.is_key () || b.is_joy ()) shortcut[i - NUM_JOYPAD_LINKS] = b; else shortcut[i - NUM_JOYPAD_LINKS].clear (); } } } return 0; }
/** * return the XML node for rls-services matching uri */ xmlNodePtr rls_get_by_service_uri(xmlDocPtr doc, str* uri) { xmlNodePtr root, node; char* val; root = XMLDocGetNodeByName(doc, "rls-services", NULL); if(root==NULL) { LM_ERR("no rls-services node in XML document\n"); return NULL; } for(node=root->children; node; node=node->next) { if(xmlStrcasecmp(node->name, (unsigned char*)"service")==0) { val = XMLNodeGetAttrContentByName(node, "uri"); if(val!=NULL) { if((uri->len==strlen(val)) && (strncmp(val, uri->s, uri->len)==0)) { xmlFree(val); return node; } xmlFree(val); } } } return NULL; }
void ReadIndexXML(xmlNode * a_node) { xmlNode *cur_node=NULL; for (cur_node = a_node; cur_node; cur_node = cur_node->next) { if (cur_node->type==XML_ELEMENT_NODE){ if(!xmlStrcasecmp(cur_node->name,(xmlChar*)"Category")){ xmlDocPtr doc; char tmp[100]; Category[num_category].Name=NULL; MY_XMLSTRCPY(&Category[num_category].Name, (char*)cur_node->children->content); num_category++; //we load the category now safe_snprintf(tmp,sizeof(tmp),"languages/%s/Encyclopedia/%s.xml",lang,cur_node->children->content); doc=xmlReadFile(tmp, NULL, 0); if (doc==NULL) { safe_snprintf(tmp,sizeof(tmp),"languages/en/Encyclopedia/%s.xml",cur_node->children->content); doc=xmlReadFile(tmp, NULL, 0); } if(doc==NULL) { return; } ReadCategoryXML(xmlDocGetRootElement(doc)); xmlFreeDoc(doc); } } ReadIndexXML(cur_node->children); } }
int read_actor_defs (const char *dir, const char *index) { xmlNode *root; xmlDoc *doc; char errmsg[120], fname[120]; int ok = 1; snprintf (fname, 120, "%s/%s", dir, index); doc = xmlReadFile (fname, NULL, 0); if (doc == NULL) { snprintf (errmsg, sizeof (errmsg), "Unable to read actor definition file %s", fname); LogError (errmsg); return 0; } root = xmlDocGetRootElement (doc); if (root == NULL) { snprintf (errmsg, sizeof (errmsg), "Unable to parse actor definition file %s", fname); LogError (errmsg); ok = 0; } else if (xmlStrcasecmp (root->name, "actors") != 0) { snprintf (errmsg, sizeof (errmsg), "Unknown key \"%s\" (\"actors\" expected).", root->name); LogError (errmsg); ok = 0; } else { ok = parse_actor_defs (root); } xmlFreeDoc (doc); return ok; }
bool SDOXMLString::equalsIgnoreCase(const xmlChar* xmlString) const { if (xmlStrcasecmp(xmlForm, xmlString) == 0) return true; else return false; }
static int expect_element_end ( xmlTextReaderPtr reader, char *exp_name) { xmlChar *name; /* maybe we are already on the end element ... lets see */ if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT){ xmlChar *temp; xmlChar *temp2; temp = xmlTextReaderName(reader); temp2 = (xmlChar*)sprintf_alloc("/%s", temp); name = xmlStrdup(temp2); xmlFree(temp); free(temp2); } else { name = get_xml_element(reader); } if (name == NULL) return -1; if (xmlStrcasecmp(name+1,(xmlChar *)exp_name) != 0 || name[0] != '/'){ rrd_set_error("line %d: expected </%s> end element but found <%s>", xmlTextReaderGetParserLineNumber(reader),exp_name,name); xmlFree(name); return -1; } xmlFree(name); return 0; } /* expect_element_end */
const char *get_string_property(const xmlNode *node, const char *prop) { const xmlAttr *attr; if (node == NULL) { LOG_ERROR("Node is null!"); return ""; } for (attr = node->properties; attr; attr = attr->next) { if (attr->type == XML_ATTRIBUTE_NODE && xmlStrcasecmp (attr->name, (xmlChar *)prop) == 0) { return (const char*)attr->children->content; } } #ifdef DEBUG_XML // don't normally report this, or optional properties will report errors LOG_ERROR("Unable to find property %s in node %s\n", prop, node->name); #endif //DEBUG_XML return ""; }
int click_help_handler(window_info *win, int mx, int my, Uint32 flags) { _Text *t=Page[helppage].T.Next; if(flags&ELW_WHEEL_UP) { vscrollbar_scroll_up(help_win, help_menu_scroll_id); } else if(flags&ELW_WHEEL_DOWN) { vscrollbar_scroll_down(help_win, help_menu_scroll_id); } else { int j = vscrollbar_get_pos(help_win, help_menu_scroll_id); while(t) { int xlen=strlen(t->text)*((t->size)?11:8),ylen=(t->size)?18:15; if(t->ref && mx>(t->x) && mx<(t->x+xlen) && my>(t->y-j) && my<(t->y+ylen-j)) { //changing page int i; for(i=0; i<numpage+1; i++) { if(!xmlStrcasecmp((xmlChar*)Page[i].Name,(xmlChar*)t->ref)) { helppage=i; vscrollbar_set_pos(help_win, help_menu_scroll_id, 0); vscrollbar_set_bar_len(help_win, help_menu_scroll_id, Page[helppage].max_y); break; } } break; } t=t->Next; } } return 1; }
static void ParseDisplay (xmlDocPtr doc, xmlNodePtr node) { xmlNodePtr dnode; xmlChar* value; int width=640,height=480; bool fullscreen=false; dnode = node->xmlChildrenNode; while (dnode != NULL) { value = xmlNodeListGetString (doc, dnode->xmlChildrenNode, 1); if (value != NULL) { if (!xmlStrcmp (dnode->name, (xmlChar*)"width")) { width = atoi ((char*)value); } else if (!xmlStrcmp (dnode->name, (xmlChar*)"height")) { height = atoi ((char*)value); } else if (!xmlStrcmp (dnode->name, (xmlChar*)"fullscreen")) { if (!xmlStrcasecmp (value, (xmlChar*)"true")) fullscreen=true; } xmlFree (value); } dnode = dnode->next; } InitVideo(width,height,fullscreen); }
void parse_knowledge_item(xmlNode *in) { xmlNode * cur; int id = -1; char * strID=NULL; char * string=NULL; for(cur=in;cur;cur=cur->next){ if(cur->type == XML_ELEMENT_NODE){ if(!xmlStrcasecmp(cur->name,(xmlChar*)"Knowledge")){ if ((strID=(char*)xmlGetProp(cur,(xmlChar*)"ID"))==NULL){ LOG_ERROR("Knowledge Item does not contain an ID property."); } else { id = atoi(strID); if(cur->children && cur->children->content && MY_XMLSTRCPY(&string, (char*)cur->children->content)!=-1){ if (read_book(string, 2, id + KNOWLEDGE_BOOK_OFFSET) != NULL) { knowledge_list[id].has_book = 1; } } else { #ifndef OSX LOG_ERROR("An error occured when parsing the content of the <%s>-tag on line %d - Check it for letters that cannot be translated into iso8859-1\n", cur->name, cur->line); #else LOG_ERROR("An error occured when parsing the content of the <%s>-tag - Check it for letters that cannot be translated into iso8859-1\n", cur->name); #endif } xmlFree(strID); free(string); string = NULL; } } } } return; }
/* For each raw link, find and set the base index page */ static void find_base_pages(void) { size_t i,j,k; /* find the index in the Page list of each of the base pages */ for (j=0; j<NUM_PAGE_INDEX; j++) for (i=0; i<numpage; ++i) if(!xmlStrcasecmp((xmlChar*)index_name[j],(xmlChar*)Page[i].Name)) { page_index[j] = i; break; } for (i=0; i<num_raw_page_links; ++i) { size_t from_page_index = raw_page_links[i].from_page_index; int found_base = 0; /* limit loops to avoid never exiting */ for (k=0; k<10 && !found_base; k++) { /* if the from page is one of the base pages, we're done */ for (j=0; j<NUM_PAGE_INDEX; j++) if (from_page_index == page_index[j]) { found_base = 1; raw_page_links[i].from_page_index = page_index[j]; break; } if (found_base) break; /* find the first occurance of from_page_index in the raw list */ for (j=0; j<num_raw_page_links; j++) if (!xmlStrcasecmp((xmlChar*)Page[from_page_index].Name, (xmlChar*)raw_page_links[j].link)) { from_page_index = raw_page_links[j].from_page_index; break; } } if (!found_base) { //printf("No base for link [%s] [%s]\n --%lu [%s]\n", raw_page_links[i].title, raw_page_links[i].link, (unsigned long)raw_page_links[i].from_page_index, Page[raw_page_links[i].from_page_index].Name); raw_page_links[i].title = NULL; } } }
xmlNodePtr xmlNodeGetNodeByName(xmlNodePtr node, const char *name, const char *ns) { xmlNodePtr cur = node; while (cur) { xmlNodePtr match = NULL; if (xmlStrcasecmp(cur->name, (unsigned char*)name) == 0) { if (!ns || (cur->ns && xmlStrcasecmp(cur->ns->prefix, (unsigned char*)ns) == 0)) return cur; } match = xmlNodeGetNodeByName(cur->children, name, ns); if (match) return match; cur = cur->next; } return NULL; }
void add_xml_page(xmlNode *cur, book * b) { page *p=add_page(b); for(;cur;cur=cur->next){ if(cur->type == XML_ELEMENT_NODE){ if (!xmlStrcasecmp(cur->name,(xmlChar*)"title")){ add_xml_str_to_page(cur,_TITLE,b,p); } else if (!xmlStrcasecmp(cur->name,(xmlChar*)"author")){ add_xml_str_to_page(cur,_AUTHOR,b,p); } else if (!xmlStrcasecmp(cur->name,(xmlChar*)"text")){ add_xml_str_to_page(cur,_TEXT,b,p); } else if (!xmlStrcasecmp(cur->name,(xmlChar*)"image")){ add_xml_image_to_page(cur, b, p); } } } }
void xmlNodeMapByName(xmlNodePtr node, const char *name, const char *ns, void (f)(xmlNodePtr, void*), void *data) { xmlNodePtr cur = node; if (!f) return; while (cur) { if (xmlStrcasecmp(cur->name, (unsigned char*)name) == 0) { if (!ns || (cur->ns && xmlStrcasecmp(cur->ns->prefix, (unsigned char*)ns) == 0)) f(cur, data); } /* visit children */ xmlNodeMapByName(cur->children, name, ns, f, data); cur = cur->next; } }