static void parse_item_tag (feedParserCtxtPtr ctxt, xmlNodePtr cur) { gchar *uri = NULL; if (!xmlStrcmp (BAD_CAST"commentRss", cur->name) || !xmlStrcmp (BAD_CAST"commentRSS", cur->name)) uri = (gchar *)xmlNodeListGetString (cur->doc, cur->xmlChildrenNode, 1); if (uri) { metadata_list_set (&(ctxt->item->metadata), "commentFeedUri", uri); g_free (uri); } }
static int parseSynStyleSrcIp(xmlDocPtr doc, xmlNodePtr cur,int randomnum) { xmlChar * temp; cur = cur->xmlChildrenNode; while(cur!=NULL){ if(randomnum==2&&!xmlStrcmp(cur->name,(const xmlChar *)"value")){ temp = xmlNodeListGetString(doc,cur->xmlChildrenNode,1); strcpy(synConTemp->srcIpValue,(char *)temp); xmlFree(temp); } else if(randomnum==1&&!xmlStrcmp(cur->name,(const xmlChar *)"scope")){ temp = xmlNodeListGetString(doc,cur->xmlChildrenNode,1); //synConTemp->srcIpls = get_ls_arr((char *)temp); if(temp) { char *p=strstr((char *)temp,","); int str_f_l=p-(char *)temp; char str_f[100]; memcpy(str_f,(char *)temp,str_f_l); str_f[str_f_l]=0; synConTemp->srcip_s = ntohl(int_aton(str_f)); synConTemp->srcip_e = ntohl(int_aton(p+1)); printf("sip scope[%d][%s]-",synConTemp->srcip_s,str_f); printf("[%d][%s]\n",synConTemp->srcip_e,p+1); } xmlFree(temp); } else if(randomnum==1&&!xmlStrcmp(cur->name,(const xmlChar *)"meth")){ temp = xmlNodeListGetString(doc,cur->xmlChildrenNode,1); synConTemp->srcIpMeth=atoi((char *)temp); xmlFree(temp); } cur = cur->next; } return 1; }
static void model_parseMavlinkParam (xmlDocPtr doc, xmlNodePtr cur, uint16_t param) { xmlChar *key; cur = cur->xmlChildrenNode; while (cur != NULL) { if ((!xmlStrcasecmp(cur->name, (const xmlChar *)"name"))) { key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); if ((char *)key != NULL) { strncpy(MavLinkVars[param].name, (char *)key, 20); } xmlFree(key); } else if ((!xmlStrcasecmp(cur->name, (const xmlChar *)"value"))) { key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); if ((char *)key != NULL) { MavLinkVars[param].value = atof((char *)key); MavLinkVars[param].onload = atof((char *)key); } xmlFree(key); } cur = cur->next; } return; }
static void ns_syn_parse_tag (feedParserCtxtPtr ctxt, xmlNodePtr cur) { xmlChar *tmp; gint period; gint frequency = 1; period = subscription_get_default_update_interval (ctxt->subscription); if (!xmlStrcmp (cur->name, BAD_CAST"updatePeriod")) { if (NULL != (tmp = xmlNodeListGetString (cur->doc, cur->xmlChildrenNode, 1))) { if (!xmlStrcmp (tmp, BAD_CAST"hourly")) period = 60; else if (!xmlStrcmp (tmp, BAD_CAST"daily")) period = 60*24; else if (!xmlStrcmp (tmp, BAD_CAST"weekly")) period = 7*24*60; else if (!xmlStrcmp (tmp, BAD_CAST"monthly")) /* FIXME: not really exact...*/ period = 31*7*24*60; else if (!xmlStrcmp (tmp, BAD_CAST"yearly")) period = 365*24*60; xmlFree (tmp); } } else if (!xmlStrcmp (cur->name, BAD_CAST"updateFrequency")) { tmp = xmlNodeListGetString (cur->doc, cur->xmlChildrenNode, 1); if (tmp) { frequency = atoi ((gchar *)tmp); xmlFree (tmp); } } /* postprocessing */ if (0 != frequency) period /= frequency; subscription_set_default_update_interval (ctxt->subscription, period); }
static void atom10_parse_feed_icon (xmlNodePtr cur, feedParserCtxtPtr ctxt, struct atom10ParserState *state) { gchar *icon_uri; icon_uri = (gchar *)xmlNodeListGetString (cur->doc, cur->xmlChildrenNode, 1); if (icon_uri) { debug1 (DEBUG_PARSING, "icon URI found in atom feed: %s", icon_uri); ctxt->subscription->metadata = metadata_list_append (ctxt->subscription->metadata, "icon", icon_uri); } }
/* Get graphics data */ static void libgadget_sidegadget_xml_parse_graphics (xmlDocPtr doc, xmlNodePtr cur, sidegadget_core_s *sidegadget) { xmlChar *key; cur = cur->xmlChildrenNode; while (cur != NULL) { if ((!xmlStrcmp (cur->name, (const xmlChar *) "height"))) { key = xmlNodeListGetString (doc, cur->xmlChildrenNode, 1); sidegadget->height = atoi (key); xmlFree (key); } else if ((!xmlStrcmp (cur->name, (const xmlChar *) "vspacing"))) { key = xmlNodeListGetString (doc, cur->xmlChildrenNode, 1); sidegadget->vspacing = atoi (key); xmlFree (key); } cur = cur->next; } return; }
/*函数功能:获取xml节点的值 *函数参数:doc:打开的xml文件句柄 cur:当前节点 key:用于指向存放内容的指针 name:节点名称 *函数返回值:成功返回0 失败返回-1 */ inline int CConfig::GetNodeValue(xmlDocPtr doc, xmlNodePtr cur, xmlChar **key, char *name) { if(cur == NULL || doc == NULL) return FAULT; if ((!xmlStrcmp(cur->name, (const xmlChar *)name))){ if((*key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)) != NULL){ return TURE; } } return FAULT; }
void _parseData(xmlDocPtr weather, xmlNodePtr cur) { xmlChar *datum; cur = cur->xmlChildrenNode; while ( cur ) { if ( !xmlStrcmp((const xmlChar * )cur->name, (const xmlChar * )"description") ) { datum = xmlNodeListGetString(weather, cur->xmlChildrenNode, 1); printf("datum: %s\n", datum); xmlFree(datum); } cur = cur->next; } }
/** * This parses an Atom content construct. * * @param cur the XML node to be parsed * @param ctxt a valid feed parser context * @returns g_strduped string which must be freed by the caller. */ static gchar * atom10_parse_content_construct (xmlNodePtr cur, feedParserCtxtPtr ctxt) { gchar *ret = NULL; if (xmlHasNsProp (cur, BAD_CAST"src", NULL )) { /* RFC 4287 says a feed must have a summary when there's a src attribute in the content (and the content therefore empty). We are already parsing the summary separately. RFC 4287 also says an entry must contain one link element with rel="alternate", so there's no point in parsing src and setting it as link. */ ret = NULL; } else { gchar *type; /* determine encoding mode */ type = xml_get_ns_attribute (cur, "type", NULL); /* Contents need to be de-encoded and should not contain sub-tags.*/ if (type && (g_str_equal (type,"html") || !g_ascii_strcasecmp (type, "text/html"))) { ret = xhtml_extract (cur, 0, NULL); } else if (!type || !strcmp (type, "text") || !strncasecmp (type, "text/",5)) { gchar *tmp; /* Assume that "text/ *" files can be directly displayed.. kinda stated in the RFC */ ret = (gchar *)xmlNodeListGetString (cur->doc, cur->xmlChildrenNode, 1); g_strchug (g_strchomp (ret)); if (!type || !strcasecmp (type, "text")) tmp = atom10_mark_up_text_content (ret); else tmp = g_markup_printf_escaped ("<pre>%s</pre>", ret); g_free (ret); ret = tmp; } else if (!strcmp(type,"xhtml") || !g_ascii_strcasecmp (type, "application/xhtml+xml")) { /* The spec says to only show the contents of the div tag that MUST be present */ ret = xhtml_extract (cur, 2, NULL); } else { /* Do nothing on unsupported content types. This allows summaries to be used. */ ret = NULL; } g_free (type); } return ret; }
static void _parse_listen_socket(xmlDocPtr doc, xmlNodePtr node, ice_config_t *configuration) { listener_t *listener = NULL; int i; char *tmp; for(i=0; i < MAX_LISTEN_SOCKETS; i++) { if(configuration->listeners[i].port <= 0) { listener = &(configuration->listeners[i]); break; } } if (listener == NULL) return; do { if (node == NULL) break; if (xmlIsBlankNode(node)) continue; if (strcmp(node->name, "port") == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); if(configuration->port == 0) configuration->port = atoi(tmp); listener->port = atoi(tmp); if(tmp) xmlFree(tmp); } else if (strcmp(node->name, "shoutcast-compat") == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); listener->shoutcast_compat = atoi(tmp); if(tmp) xmlFree(tmp); } else if (strcmp(node->name, "bind-address") == 0) { listener->bind_address = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); } } while ((node = node->next)); }
static void ns_itunes_parse_item_tag (feedParserCtxtPtr ctxt, xmlNodePtr cur) { gchar *tmp; if (!xmlStrcmp(cur->name, BAD_CAST"author")) { tmp = (gchar *)xmlNodeListGetString (cur->doc, cur->xmlChildrenNode, 1); if (tmp) { ctxt->item->metadata = metadata_list_append (ctxt->item->metadata, "author", tmp); g_free (tmp); } } if (!xmlStrcmp (cur->name, BAD_CAST"summary")) { tmp = xhtml_extract (cur, 0, NULL); item_set_description (ctxt->item, tmp); g_free (tmp); } if (!xmlStrcmp(cur->name, BAD_CAST"keywords")) { gchar *keyword = tmp = (gchar *)xmlNodeListGetString (cur->doc, cur->xmlChildrenNode, 1); gchar *allocated = tmp; /* parse comma separated list and strip leading spaces... */ while (tmp) { tmp = strchr (tmp, ','); if (tmp) { *tmp = 0; tmp++; } while (g_unichar_isspace (*keyword)) { keyword = g_utf8_next_char (keyword); } ctxt->item->metadata = metadata_list_append (ctxt->item->metadata, "category", keyword); keyword = tmp; } g_free (allocated); } }
void xml_delete(int sock, xmlDocPtr doc, xmlNodePtr top) { xmlNodePtr n; xmlChar *coll; fprintf(stderr, "Going to delete something!\n"); if ((n = xml_find_child(top, "collection")) == NULL) { fprintf(stderr, "Unable to find collection to delete from\n"); return; } if ((coll = xmlNodeListGetString(doc, n->xmlChildrenNode, 1)) == NULL) { fprintf(stderr, "Unable to get collection name from delete\n"); return; } for (n = top->xmlChildrenNode; n != NULL; n = n->next) { xmlChar *p; if (xmlStrcmp(n->name, (xmlChar*)"uri") != 0) { fprintf(stderr, "Unknown node(delete) name: %s\n", (char *)n->name); continue; } if ((p = xmlNodeListGetString(doc, n->xmlChildrenNode, 1)) == NULL) { fprintf(stderr, "Unable to get uri to delete.\n"); continue; } bbdn_deleteuri(sock, (char *)coll, (char *)p); xmlFree(p); } xmlFree(coll); }
/** * Parse a IMS Subscription. * @param doc - the XML document * @param root - the current node * @returns the ims_subscription* on success or NULL on error */ static ims_subscription* parse_ims_subscription(xmlDocPtr doc, xmlNodePtr root) { xmlNodePtr child; xmlChar *x; ims_subscription *s; unsigned short sp_cnt=0; if (!root) return 0; while(root->type!=XML_ELEMENT_NODE || strcasecmp(root->name,"IMSSubscription")!=0){ root = root->next; } if (!root) { LOG(L_ERR,"ERR:"M_NAME":parse_user_data: No IMSSubscription node found\n"); return 0; } s = (ims_subscription*) shm_malloc(sizeof(ims_subscription)); if (!s) { LOG(L_ERR,"ERR:"M_NAME":parse_ims_subscription: Out of memory allocating %d bytes\n",sizeof(ims_subscription)); return 0; } memset(s,0,sizeof(ims_subscription)); for(child=root->children;child;child=child->next) if (child->type==XML_ELEMENT_NODE) switch (child->name[0]){ case 'P':case 'p': /* Private Identity */ if (!s->private_identity.len){ x = xmlNodeListGetString(doc,child->xmlChildrenNode,1); space_trim_dup(&(s->private_identity),x); xmlFree(x); } break; case 'S':case 's': /* Service Profile */ sp_cnt++; break; } s->service_profiles = (ims_service_profile*) shm_malloc(sp_cnt * sizeof(ims_service_profile)); if (!s->service_profiles) { LOG(L_ERR,"ERR:"M_NAME":parse_ims_subscription: Out of memory allocating %d bytes\n",sp_cnt*sizeof(ims_service_profile)); return s; } memset(s->service_profiles,0,sp_cnt * sizeof(ims_service_profile)); for(child=root->children;child;child=child->next) if (child->type==XML_ELEMENT_NODE) if (child->name[0]=='S' || child->name[0]=='s') if (parse_service_profile(doc,child,&(s->service_profiles[s->service_profiles_cnt]))) s->service_profiles_cnt++; s->lock = lock_alloc(); s->lock = lock_init(s->lock); return s; }
/** * Parse SPT for Session Description. * @param doc - the XML document * @param node - the current node * @param sd - structure to fill * @returns 1 on success, 0 on failure */ static int parse_session_desc(xmlDocPtr doc,xmlNodePtr node,ims_session_desc *sd) { xmlNodePtr child; xmlChar *x; sd->line.s=NULL;sd->line.len=0; sd->content.s=NULL;sd->content.len=0; for(child=node->children ; child ; child=child->next) if (child->type==XML_ELEMENT_NODE) switch (child->name[0]) { case 'L':case 'l': //Line x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); space_trim_dup(&(sd->line),(char*)x); xmlFree(x); break; case 'C':case 'c': //Content x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); space_quotes_trim_dup(&(sd->content),(char*)x); xmlFree(x); break; } return 1; }
/* * get value of attribute attrName of node. NULL if attribute not found */ const char *getElemAttr(void *node, const char *attrName) { if (!node) return NULL; xmlAttr* attribute = ((xmlNodePtr) node)->properties; while (attribute) { if ((!xmlStrcmp(attribute->name, (const xmlChar *) attrName))) { xmlChar* value = xmlNodeListGetString(((xmlNodePtr) node)->doc, attribute->children, 1); return (const char *) value; } attribute = attribute->next; } return NULL; }
int process_data(xmlDocPtr doc, xmlNodePtr node, char *xpath, int level, char *fn) { char *newxpath = NULL; char *data = NULL; int size, i, found; node = node->xmlChildrenNode; while (node != NULL) { data = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); if ((data != NULL) && ((strlen(data) == 0) || (data[0] == 10))) { size = strlen(xpath) + strlen((const char *)node->name) + 2; newxpath = (char *)utils_alloc( "xml.process_data.newxpath", size * sizeof(char) ); snprintf(newxpath, size, "%s/%s", xpath, node->name); process_recursive(doc, newxpath, level + 1, fn); newxpath = utils_free("xml.process_data.newxpath", newxpath); } else if (data != NULL) { found = 0; for (i = 0; i < xml_numAttr; i++) { if ((strcmp(xattr[i].name, (const char *)node->name) == 0) && ((strcmp(xattr[i].node, xpath) == 0)) && ((strcmp(xattr[i].value, data) == 0)) && ((strcmp(xattr[i].filename, fn) == 0))) found = 1; } if (!found) { if (xattr == NULL) xattr = (tAttr *)utils_alloc( "xml.process_data.xattr", sizeof(tAttr) ); else xattr = (tAttr *)realloc( xattr, (xml_numAttr + 1) * sizeof(tAttr) ); xattr[xml_numAttr].name = strdup( (const char *)node->name); xattr[xml_numAttr].node = strdup(xpath); xattr[xml_numAttr].value = strdup(data); xattr[xml_numAttr].filename = strdup(fn); xattr[xml_numAttr].numIter = xml_numIter; xml_numAttr++; } } data = utils_free("xml.process_data.data", data); node = node->next; } xml_numIter++; return 0; }
// ------------------------------------------------------------- const char* Webpage::getNodeContents(string exp) { const xmlChar* contents; xmlXPathObjectPtr obj = xpath(exp); xmlNodeSetPtr nodeset = obj->nodesetval; if(nodeset && nodeset->nodeNr > 0) { contents = xmlNodeListGetString(doc, nodeset->nodeTab[0]->children, 1); } xmlXPathFreeObject(obj); return (const char*)contents; }
// --------------------------------------------------------------------------------------------- // @return Compex value of the attribute, // probably consisting of text nodes and entity references // // Since the value may be composed from a set of TXmlEngTextNode and EntityRefernce nodes, // the returned result is newly allocated string, which should be freed by caller. // // <B style="color: red">BE SURE TO FREE THE RESULT STRING!!!</B> // // On Symbian: // @code // // Note the use of AllocAndFreeLC(), which converts value to // // UTF-16 descriptor, pushes it to the cleanup stack and // // DEALLOCATES string in the returned TDOMString object // HBufC* value = attr.WholeValueCopyL().AllocAndFreeLC(); // ... // CleanupStack::PopAndDestroy(); // value; // @endcode // // @see TXmlEngAttr::Value(), TXmlEngNode::Value(), // TXmlEngNode::IsSimpleTextContents(), TXmlEngNode::WholeTextContentsCopyL() // // @note In most cases using Value() is enough (and it needs no memory allocation). // Use IsSimpleTextContents() if there doubts can Value() be used or not safely. // --------------------------------------------------------------------------------------------- // EXPORT_C void TXmlEngAttr::WholeValueCopyL(RBuf8& aBuffer) const { if (!LIBXML_ATTRIBUTE) { User::Leave(KXmlEngErrNullNode); } // xmlChar* value = xmlNodeListGetString( LIBXML_ATTRIBUTE->doc, LIBXML_ATTRIBUTE->children, 1); TEST_OOM_FLAG; xmlCharAssignToRbuf8L(aBuffer,value); }
/** * Parse the Public Identity. * @param doc - the XML document * @param root - the current node * @param pi - structure to fill * @returns 1 on success, 0 on failure */ static int parse_public_identity(xmlDocPtr doc, xmlNodePtr root, ims_public_identity *pi) { xmlNodePtr child; xmlChar *x; for(child=root->children;child;child=child->next) if (child->type==XML_ELEMENT_NODE) switch (child->name[0]){ case 'I': case 'i': if (!pi->public_identity.len){ x = xmlNodeListGetString(doc,child->xmlChildrenNode,1); space_trim_dup(&(pi->public_identity),x); xmlFree(x); } break; case 'B': case 'b': x = xmlNodeListGetString(doc,child->xmlChildrenNode,1); pi->barring = ifc_tBool2char(x); xmlFree(x); break; } return 1; }
void parseStory (xmlDocPtr doc, xmlNodePtr cur) { xmlChar *key; cur = cur->xmlChildrenNode; while (cur != NULL) { if ((!xmlStrcmp(cur->name, (const xmlChar *)"keyword"))) { key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); printf("keyword: %s\n", key); xmlFree(key); } cur = cur->next; } return; }
static void atom10_parse_entry_updated (xmlNodePtr cur, feedParserCtxtPtr ctxt, struct atom10ParserState *state) { gchar *datestr; datestr = (gchar *)xmlNodeListGetString (cur->doc, cur->xmlChildrenNode, 1); /* if pubDate is already set, don't overwrite it */ if (datestr && !metadata_list_get(ctxt->item->metadata, "pubDate")) { ctxt->item->time = date_parse_ISO8601 (datestr); ctxt->item->metadata = metadata_list_append (ctxt->item->metadata, "contentUpdateDate", datestr); } g_free (datestr); }
int config_get_str (xmlNodePtr node, void *x) { if (xmlIsBlankNode (node) == 0) { xmlChar *str = xmlNodeListGetString (node->doc, node->xmlChildrenNode, 1); xmlChar *p = *(xmlChar**)x; if (str == NULL) return 1; if (p) xmlFree (p); *(xmlChar **)x = str; } return 0; }
static void atom10_parse_entry_id (xmlNodePtr cur, feedParserCtxtPtr ctxt, struct atom10ParserState *state) { gchar *id; id = (gchar *)xmlNodeListGetString (cur->doc, cur->xmlChildrenNode, 1); if (id) { if (strlen (id) > 0) { item_set_id (ctxt->item, id); ctxt->item->validGuid = TRUE; } g_free (id); } }
int cthd_parse::parse_new_platform(xmlNode * a_node, xmlDoc *doc, thermal_info_t *info_ptr) { xmlNode *cur_node = NULL; unsigned char *tmp_value; thermal_info_t info; for (cur_node = a_node; cur_node; cur_node = cur_node->next) { if (cur_node->type == XML_ELEMENT_NODE) { DEBUG_PARSER_PRINT("node type: Element, name: %s value: %s\n", cur_node->name, xmlNodeListGetString(doc, cur_node->xmlChildrenNode, 1)); tmp_value = (unsigned char*)xmlNodeListGetString(doc, cur_node->xmlChildrenNode, 1); if (!strcmp((const char*)cur_node->name, "Platform")) { info.cooling_devs.clear(); info.zones.clear(); parse_new_platform_info(cur_node->children, doc, &info); thermal_info_list.push_back(info); } if (tmp_value) xmlFree(tmp_value); } } return THD_SUCCESS; }
int cthd_parse::parse_pid_values(xmlNode * a_node, xmlDoc *doc, thermal_zone_t *info_ptr) { xmlNode *cur_node = NULL; char *tmp_value; for (cur_node = a_node; cur_node; cur_node = cur_node->next) { if (cur_node->type == XML_ELEMENT_NODE) { DEBUG_PARSER_PRINT("node type: Element, name: %s value: %s\n", cur_node->name, xmlNodeListGetString(doc, cur_node->xmlChildrenNode, 1)); tmp_value = (char*)xmlNodeListGetString(doc, cur_node->xmlChildrenNode, 1); if (!strcmp((const char*)cur_node->name, "Kp")) { info_ptr->pid.Kp = atof(tmp_value); } else if (!strcmp((const char*)cur_node->name, "Kd")) { info_ptr->pid.Kd = atof(tmp_value); } else if (!strcmp((const char*)cur_node->name, "Ki")) { info_ptr->pid.Ki = atof(tmp_value); } if (tmp_value) xmlFree(tmp_value); } } return THD_SUCCESS; }
static gboolean parse_tag (Tag *tag, xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) { /* pluma_debug_message (DEBUG_PLUGINS, " Tag name: %s", tag->name); */ /* We don't care what the top level element name is */ cur = cur->xmlChildrenNode; while (cur != NULL) { if ((!xmlStrcmp (cur->name, (const xmlChar *)"Begin")) && (cur->ns == ns)) { tag->begin = xmlNodeListGetString (doc, cur->xmlChildrenNode, 1); /* pluma_debug_message (DEBUG_PLUGINS, " - Begin: %s", tag->begin); */ } if ((!xmlStrcmp (cur->name, (const xmlChar *)"End")) && (cur->ns == ns)) { tag->end = xmlNodeListGetString (doc, cur->xmlChildrenNode, 1); /* pluma_debug_message (DEBUG_PLUGINS, " - End: %s", tag->end); */ } cur = cur->next; } if ((tag->begin == NULL) && (tag->end == NULL)) return FALSE; return TRUE; }
int assign_id_attributes(xmlDocPtr doc) { // Assume the ID attribute is one of (ID | Id | id) and tell this to libxml xmlXPathContextPtr xpathCtx = xmlXPathNewContext(doc); if(xpathCtx == NULL) { xmlFreeDoc(doc); rb_raise(rb_eRuntimeError,"Error: unable to create new XPath context\n"); return(-1); } xmlChar* xpathExpr = "//*[@ID | @Id | @id]"; xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx); if(xpathObj == NULL) { xmlXPathFreeContext(xpathCtx); xmlFreeDoc(doc); rb_raise(rb_eRuntimeError,"Error: unable to evaluate xpath expression \"%s\"\n", xpathExpr); return(-1); } xmlNodeSetPtr nodes = xpathObj->nodesetval; int size = (nodes) ? nodes->nodeNr : 0; char* idNames[] = {"ID", "Id", "id"}; xmlAttrPtr attr, tmp; int i,j; for(i = 0; i < size; i++) { for(j=0; j<3;j++) { tmp = xmlHasProp(nodes->nodeTab[i], idNames[j]); if(tmp != NULL) attr = tmp; } if(attr == NULL) { xmlXPathFreeContext(xpathCtx); return(-1); } xmlChar* name = xmlNodeListGetString(doc, attr->children, 1); if(name == NULL) { xmlXPathFreeContext(xpathCtx); return(-1); } xmlAttrPtr tmp = xmlGetID(doc, name); if(tmp != NULL) { xmlFree(name); return 0; } xmlAddID(NULL, doc, name, attr); xmlFree(name); } xmlXPathFreeObject(xpathObj); xmlXPathFreeContext(xpathCtx); }
/** * Parses "Sinks" child of the configuration */ void parseSinks(xmlDocPtr doc, xmlNodePtr cur, config *conf) { xmlChar *txt; xmlNodePtr sub, subsub; cur = cur->xmlChildrenNode; while (cur != NULL) { if((!xmlStrcmp(cur->name, (const xmlChar *)"sink"))) { sub = cur->xmlChildrenNode; while (sub != NULL) { if ((!xmlStrcmp(sub->name, (const xmlChar *)"id"))) { txt = xmlNodeListGetString(doc, sub->xmlChildrenNode, 1); log << "\nid = " << txt << "\n"; xmlFree(txt); } else if (!xmlStrcmp(sub->name, (const xmlChar *)"location")) { txt = xmlGetProp( sub, (const xmlChar *)"type"); if (txt) { log << "location type = " << txt << ":\n"; xmlFree( txt ); subsub = sub->xmlChildrenNode; while (subsub != NULL) { if (subsub->type == XML_ELEMENT_NODE) { log << "\t\t " << subsub->name << " "; txt = xmlNodeListGetString(doc, subsub->xmlChildrenNode, 1); log << txt << "\n"; xmlFree(txt); } subsub = subsub->next; } } } sub = sub->next; } } cur = cur->next; } }
gchar * parseAuthor(xmlNodePtr cur) { gchar *tmp = NULL; gchar *tmp2, *tmp3; g_assert(NULL != cur); cur = cur->xmlChildrenNode; while (cur != NULL) { if(NULL == cur->name) { g_warning("invalid XML: parser returns NULL value -> tag ignored!"); cur = cur->next; continue; } if (!xmlStrcmp(cur->name, BAD_CAST"name")) tmp = (gchar *)xmlNodeListGetString(cur->doc, cur->xmlChildrenNode, 1); if (!xmlStrcmp(cur->name, BAD_CAST"email")) { tmp2 = (gchar *)xmlNodeListGetString(cur->doc, cur->xmlChildrenNode, 1); tmp3 = g_strdup_printf("%s <a href=\"mailto:%s\">%s</a>", tmp, tmp2, tmp2); g_free(tmp); g_free(tmp2); tmp = tmp3; } if (!xmlStrcmp(cur->name, BAD_CAST"url")) { tmp2 = (gchar *)xmlNodeListGetString(cur->doc, cur->xmlChildrenNode, 1); tmp3 = g_strdup_printf("%s (<a href=\"%s\">%s</a>)", tmp, tmp2, _("Website")); g_free(tmp); g_free(tmp2); tmp = tmp3; } cur = cur->next; } return tmp; }
static void load_video_stream(xmlDocPtr xml_doc, xmlNodePtr node, bg_nle_video_stream_t * ret) { char * tmp_string; if((tmp_string = BG_XML_GET_PROP(node, "scale"))) { ret->timescale = atoi(tmp_string); free(tmp_string); } node = node->children; while(node) { if(!node->name) { node = node->next; continue; } if(!BG_XML_STRCMP(node->name, tc_rate_name)) { tmp_string = (char*)xmlNodeListGetString(xml_doc, node->children, 1); ret->tc_format.int_framerate = strtol(tmp_string, (char**)0, 10); fprintf(stderr, "Timecode rate: %d\n", ret->tc_format.int_framerate); xmlFree(tmp_string); } else if(!BG_XML_STRCMP(node->name, tc_flags_name)) { tmp_string = (char*)xmlNodeListGetString(xml_doc, node->children, 1); ret->tc_format.flags = strtol(tmp_string, (char**)0, 10); xmlFree(tmp_string); } node = node->next; } }