TileMapParseStatus TileMapLayer_parse_data(xmlTextReaderPtr reader, TileMap *map, TileMapLayer *layer) { TileMapParseStatus status = TILEMAP_PARSE_OK; while (xmlTextReaderMoveToNextAttribute(reader)) { xmlChar *attrName = xmlTextReaderName(reader); xmlChar *attrVal = xmlTextReaderValue(reader); if (streq(attrName, "encoding")) { check(streq(attrVal, "base64"), "Incorrect layer data encoding"); } else if (streq(attrName, "compression")) { check(streq(attrVal, "gzip"), "Incorrect layer data compression"); } } while (xmlTextReaderRead(reader)) { xmlChar *childName = xmlTextReaderName(reader); if (xmlTextReaderNodeType(reader) == XML_ELEMENT_DECL && streq(childName, "data")) { break; } else if (xmlTextReaderNodeType(reader) == XML_TEXT_NODE) { int tile_count = 0; extract_gids_from_encoded_data(xmlTextReaderValue(reader), &(layer->tile_gids), &tile_count); check(tile_count == map->rows * map->cols, "Inconsistent layer size"); layer->gid_count = tile_count; } } return status; error: return TILEMAP_PARSE_INVALID_FORMAT; }
/* * Parse the configuration file's pg element about connection information */ static void ows_parse_config_pg(ows * o, xmlTextReaderPtr r) { xmlChar *a, *v; assert(o); assert(r); if (xmlTextReaderMoveToFirstAttribute(r) != 1) return; do { a = xmlTextReaderName(r); if ( !strcmp((char *) a, "host") || !strcmp((char *) a, "user") || !strcmp((char *) a, "password") || !strcmp((char *) a, "dbname") || !strcmp((char *) a, "port")) { v = xmlTextReaderValue(r); buffer_add_str(o->pg_dsn, (char *) a); buffer_add_str(o->pg_dsn, "="); buffer_add_str(o->pg_dsn, (char *) v); buffer_add_str(o->pg_dsn, " "); xmlFree(v); } else if (!strcmp((char *) a, "encoding")) { v = xmlTextReaderValue(r); buffer_add_str(o->db_encoding, (char *) v); xmlFree(v); } xmlFree(a); } while (xmlTextReaderMoveToNextAttribute(r) == 1); if (!o->db_encoding->use) buffer_add_str(o->db_encoding, OWS_DEFAULT_DB_ENCODING); }
//Parse AC flight plan xml (block & waypoint names void parse_ac_fp(int DevNameIndex, char *filename) { xmlTextReaderPtr reader; int ret; reader = xmlReaderForFile(filename, NULL, XML_PARSE_NOWARNING | XML_PARSE_NOERROR); /* Dont validate with the DTD */ xmlChar *name, *value; if (reader != NULL) { ret = xmlTextReaderRead(reader); int wp_queue=1; int bl_queue=1; while (ret == 1) { name = xmlTextReaderName(reader); if (name == NULL) { name = xmlStrdup(BAD_CAST "--"); } //read waypoint names if (xmlStrEqual(name, (const xmlChar *)"waypoint")) { //waypoint node read name attr. xmlTextReaderMoveToAttribute(reader,(const xmlChar *)"name"); value = xmlTextReaderValue(reader); //copy it to DevNames[] structure strcpy(DevNames[DevNameIndex].AcWp[wp_queue].Wp_Name, (char *) value); wp_queue++; } if (xmlStrEqual(name, (const xmlChar *)"block")) { //Read block names if ( xmlTextReaderAttributeCount(reader) >= 1 ) { xmlTextReaderMoveToAttribute(reader,(const xmlChar *)"name"); value = xmlTextReaderValue(reader); strcpy(DevNames[DevNameIndex].AcBl[bl_queue].Bl_Name, (char *) value); bl_queue++; } } ret = xmlTextReaderRead(reader); } xmlFreeTextReader(reader); if (ret != 0) { if (verbose) { printf("App Server: failed to parse %s\n", filename); fflush(stdout); } } } else { if (verbose) { printf("App Server: Unable to open %s\n", filename); fflush(stdout); } } }
static int _exml_read(EXML *xml, xmlTextReaderPtr reader) { int empty; xmlChar *name, *value; if (!reader) return -1; exml_clear( xml ); while( xmlTextReaderRead( reader ) == 1 ) { name = xmlTextReaderName(reader); value = xmlTextReaderValue(reader); empty = xmlTextReaderIsEmptyElement(reader); switch( xmlTextReaderNodeType(reader) ) { case XML_READER_TYPE_ELEMENT: exml_start(xml); exml_tag_set(xml, (char *) name); if (xmlTextReaderHasAttributes(reader)) { xmlTextReaderMoveToFirstAttribute(reader); do { xmlChar *attr_name, *attr_value; attr_name = xmlTextReaderName(reader); attr_value = xmlTextReaderValue(reader); exml_attribute_set(xml, (char *) attr_name, (char *) attr_value); xmlFree(attr_name); xmlFree(attr_value); } while( xmlTextReaderMoveToNextAttribute(reader) == 1 ); } if (!empty) break; case XML_READER_TYPE_END_ELEMENT: exml_end(xml); break; case XML_READER_TYPE_WHITESPACE: break; case XML_READER_TYPE_TEXT: exml_value_set(xml, (char *) value); break; } xmlFree(name); xmlFree(value); } xmlTextReaderClose(reader); xmlFreeTextReader(reader); exml_goto_top( xml ); return TRUE; }
void parse_ac_af(int DevNameIndex, char *filename) { xmlTextReaderPtr reader; int ret; reader = xmlReaderForFile(filename, NULL, XML_PARSE_NOWARNING | XML_PARSE_NOERROR); /* Dont validate with the DTD */ xmlChar *name, *value; if (reader != NULL) { ret = xmlTextReaderRead(reader); while (ret == 1) { name = xmlTextReaderName(reader); if (name == NULL) { name = xmlStrdup(BAD_CAST "--"); } if (xmlStrEqual(name, (const xmlChar *)"firmware")) { xmlTextReaderMoveToAttribute(reader,(const xmlChar *)"name"); value = xmlTextReaderValue(reader); //check if firmware name is accaptable if (check_firmware_type(value)>0) { strcpy(DevNames[DevNameIndex].type, (char *) value); } } if (xmlStrEqual(name, (const xmlChar *)"define")) { xmlTextReaderMoveToAttribute(reader,(const xmlChar *)"name"); value = xmlTextReaderValue(reader); if (xmlStrEqual(value, (const xmlChar *)"AC_ICON")) { xmlTextReaderMoveToAttribute(reader,(const xmlChar *)"value"); value = xmlTextReaderValue(reader); strcpy(DevNames[DevNameIndex].type, (char *) value); return; } } ret = xmlTextReaderRead(reader); } xmlFreeTextReader(reader); if (ret != 0) { if (verbose) { printf("App Server: failed to parse %s\n", filename); fflush(stdout); } } } else { if (verbose) { printf("App Server: Unable to open %s\n", filename); fflush(stdout); } } }
// Return value: true if next node has a sub-tree bool XMLReader::nextTypeContainsChildren(xmlTextReaderPtr &reader, const string §ion_name, string &name, string &value, bool &state_end_found, int &depth) { state_end_found = false; depth = -1; int r = 1; bool done=false, subtree_found=false; while ( (r==1) && (!state_end_found) && (!done) ) { xmlChar *localName=xmlTextReaderLocalName(reader), *localValue=NULL; depth = xmlTextReaderDepth(reader); switch ( xmlTextReaderNodeType( reader ) ) { case 15: state_end_found = (xmlStrEqual(localName, BAD_CAST section_name.c_str()) != 0); break; case 1: r = xmlTextReaderRead(reader); if (r==1) { switch ( xmlTextReaderNodeType(reader) ) { case 3: if (!xmlTextReaderHasValue(reader)) throw std::runtime_error("Huh?! Expected a value now. This xml should maybe not be valid?!"); localValue = xmlTextReaderValue(reader); name = string((char *)localName); value = string((char *)localValue); r = xmlTextReaderRead(reader); done = true; break; case 14: if (!xmlTextReaderHasValue(reader)) throw std::runtime_error("Huh?! Expected a value now. This xml should maybe not be valid?!"); localValue = xmlTextReaderValue(reader); name = string((char *)localName); value = string((char *)localValue); r = xmlTextReaderRead(reader); done = true; subtree_found = true; } } } // end of switch (type) xmlFree(localName); if (localValue!=NULL) xmlFree(localValue); if (!done) r=xmlTextReaderRead(reader); } if (r==0) state_end_found = true; // If r==0, it makes no sense to scan for more stuff... return subtree_found; }
string BEXMLTextReader::value() { const xmlChar * reader_value = xmlTextReaderValue ( reader ); string value = (const char *)reader_value; xmlFree ( (void *)reader_value ); return value; }
std :: string getNextNode () { xmlChar * name, * value; do { xmlTextReaderRead (reader); name = xmlTextReaderName (reader); value = xmlTextReaderValue (reader); } while (! strcmp ((char *) name, "#text") && isSep (value)); std :: string str; if (strcmp ((char *) name, "#text")) str.assign ((char *) name); else str.assign ((char *) value); if (name) xmlFree (name); if (value) xmlFree (value); return str; }
/** * Callback for XML-Node processing **/ void processNode(xmlTextReaderPtr reader, char *objPath, ruleExecInfo_t* rei) { xmlChar *name, *value; rodsLog( LOG_NOTICE, "Calling processNode()\n"); name = xmlTextReaderName(reader); value = xmlTextReaderValue(reader); if (xmlStrEqual(name, BAD_CAST "spectrumList")) { end = 1; } else if (xmlStrEqual(name, BAD_CAST "cvParam")) { if(xmlTextReaderHasAttributes(reader) > 0) { rodsLog(LOG_NOTICE, "Extracting cvParam information...\n"); xmlChar *cvLabel = xmlTextReaderGetAttribute(reader, (xmlChar *) "cvLabel"); xmlChar *cvAccession = xmlTextReaderGetAttribute(reader, (xmlChar *) "accession"); xmlChar *cvName = xmlTextReaderGetAttribute(reader, (xmlChar *) "name"); xmlChar *cvValue = xmlTextReaderGetAttribute(reader, (xmlChar *) "name"); printf("cvParam: [%s] [%s] [%s] [%s]\n", cvLabel, cvAccession, cvName, cvValue); createMetadataOnObject(objPath, (char*) "cvParam", (char *) cvLabel, (char*) "", rei); createMetadataOnObject(objPath, (char *) cvLabel, (char *) cvValue, (char *) cvAccession, rei); createMetadataOnObject(objPath, (char *) cvLabel, (char *) cvName, (char*) "", rei); } } }
/* * _gweather_parser_get_value: * @parser: a #GWeatherParser * * Gets the text of the element whose start tag @parser is pointing to. * Leaves @parser pointing at the next node after the element's end tag. * * Return value: the text of the current node, as a libxml-allocated * string, or %NULL if the node is empty. **/ char * _gweather_parser_get_value (GWeatherParser *parser) { char *value; /* check for null node */ if (xmlTextReaderIsEmptyElement (parser->xml)) return NULL; /* the next "node" is the text node containing the value we want to get */ if (xmlTextReaderRead (parser->xml) != 1) return NULL; value = (char *) xmlTextReaderValue (parser->xml); /* move on to the end of this node */ while (xmlTextReaderNodeType (parser->xml) != XML_READER_TYPE_END_ELEMENT) { if (xmlTextReaderRead (parser->xml) != 1) { xmlFree (value); return NULL; } } /* consume the end element too */ if (xmlTextReaderRead (parser->xml) != 1) { xmlFree (value); return NULL; } return value; }
static void handle_keyword_char_class_element (ParserState *parser_state) { xmlChar *char_class; int ret, type; g_return_if_fail (parser_state->error == NULL); if (parser_state->ctx_data == NULL) return; do { ret = xmlTextReaderRead (parser_state->reader); g_assert (ret == 1); type = xmlTextReaderNodeType (parser_state->reader); } while (type != XML_READER_TYPE_TEXT && type != XML_READER_TYPE_CDATA); char_class = xmlTextReaderValue (parser_state->reader); g_free (parser_state->opening_delimiter); g_free (parser_state->closing_delimiter); parser_state->opening_delimiter = g_strdup_printf ("(?!<%s)(?=%s)", char_class, char_class); parser_state->closing_delimiter = g_strdup_printf ("(?<=%s)(?!%s)", char_class, char_class); xmlFree (char_class); }
static char *parse_text_element(xmlTextReaderPtr reader, char *name) { char *string = NULL; __attribute__nonnull__(reader); __attribute__nonnull__(name); // parse string element attributes here (like xml:lang) while (xmlTextReaderNextNode(reader)) { if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT && !xmlStrcmp(xmlTextReaderConstLocalName(reader), BAD_CAST name)) { return string; } switch (xmlTextReaderNodeType(reader)) { case XML_READER_TYPE_TEXT: string = (char *)xmlTextReaderValue(reader); break; default: oscap_seterr(OSCAP_EFAMILY_OSCAP, "Unknown XML element in platform"); break; } } return string; }
char* getElementContent(MemoryStruct *xmlDoc, char *elementName) { xmlTextReaderPtr reader; int ret; xmlChar *name, *value; reader = xmlReaderForMemory(xmlDoc->data, xmlDoc->size, "http://www.example.org/", NULL, 0); if (reader != NULL) { ret = xmlTextReaderRead(reader); while (ret == 1) { name = xmlTextReaderName(reader); if (strcmp(elementName, (char*) name) == 0 && xmlTextReaderNodeType(reader) == 1) { //printf("Name: %s\tType: %d\t", name, xmlTextReaderNodeType(reader)); ret = xmlTextReaderRead(reader); if (ret == 1) { value = xmlTextReaderValue(reader); //printf("Value: %s\n", value); //xmlFree(value); xmlFree(name); xmlFreeTextReader(reader); return (char*) value; } } xmlFree(name); ret = xmlTextReaderRead(reader); } xmlFreeTextReader(reader); if (ret != 0) printf("Failed to parse.\n"); } else printf("Unable to read XML from memory.\n"); return; }
/* -1 error; 0 OK */ int oscap_parser_text_value(xmlTextReaderPtr reader, oscap_xml_value_consumer consumer, void *user) { int depth = xmlTextReaderDepth(reader); bool has_value = false; int ret = 0; if (xmlTextReaderIsEmptyElement(reader)) { return ret; } xmlTextReaderRead(reader); while (xmlTextReaderDepth(reader) > depth) { int nodetype = xmlTextReaderNodeType(reader); if (nodetype == XML_READER_TYPE_CDATA || nodetype == XML_READER_TYPE_TEXT) { char *value = (char *)xmlTextReaderValue(reader); (*consumer) (value, user); oscap_free(value); has_value = true; } if (xmlTextReaderRead(reader) != 1) { ret = -1; break; } } if (!has_value) (*consumer) ("", user); return ret; }
//Parse dl values void parse_ac_settings(int DevNameIndex, char *filename) { xmlTextReaderPtr reader; int ret; reader = xmlReaderForFile(filename, NULL, XML_PARSE_NOWARNING | XML_PARSE_NOERROR); /* Dont validate with the DTD */ // Init some variables (-1 means no settings in xml file) DevNames[DevNameIndex].dl_launch_ind = -1; DevNames[DevNameIndex].kill_thr_ind = -1; DevNames[DevNameIndex].flight_altitude_ind = -1; xmlChar *name, *value; if (reader != NULL) { ret = xmlTextReaderRead(reader); int valind = 0; while (ret == 1) { name = xmlTextReaderName(reader); if (name == NULL) { name = xmlStrdup(BAD_CAST "--"); } if (xmlStrEqual(name, (const xmlChar *)"dl_setting")) { xmlTextReaderMoveToAttribute(reader,(const xmlChar *)"var"); value = xmlTextReaderValue(reader); if (xmlStrEqual(value, (const xmlChar *)"launch")) { DevNames[DevNameIndex].dl_launch_ind=valind; } if (xmlStrEqual(value, (const xmlChar *)"kill_throttle")) { DevNames[DevNameIndex].kill_thr_ind=valind; } if (xmlStrEqual(value, (const xmlChar *)"flight_altitude")) { DevNames[DevNameIndex].flight_altitude_ind=valind; } xmlTextReaderNext(reader); valind+=1; } ret = xmlTextReaderRead(reader); } xmlFreeTextReader(reader); if (ret != 0) { if (verbose) { printf("App Server: %s : failed to parse\n", filename); fflush(stdout); } } } else { if (verbose) { printf("App Server: Unable to open %s\n", filename); fflush(stdout); } } }
bool sc_xmltv_get_reader_value(xmlTextReaderPtr reader, char **dst) { bool ret = false; xmlChar *val = xmlTextReaderValue(reader); if (val) { *dst = sc_util_strcpy((char *) val); ret = true; } xmlFree(val); return ret; }
static xmlChar* get_xml_text ( xmlTextReaderPtr reader ) { while(xmlTextReaderRead(reader)){ xmlChar *ret; xmlChar *text; xmlChar *begin_ptr; xmlChar *end_ptr; int type; type = xmlTextReaderNodeType(reader); if (type == XML_READER_TYPE_ELEMENT){ xmlChar *name; name = xmlTextReaderName(reader); rrd_set_error("line %d: expected a value but found a <%s> element", xmlTextReaderGetParserLineNumber(reader), name); xmlFree(name); return NULL; } /* trying to read text from <a></a> we end up here lets return an empty string instead. This is a tad optimistic since we do not check if it is actually </a> and not </b> we got, but first we do not know if we expect </a> and second we the whole implementation is on the optimistic side. */ if (type == XML_READER_TYPE_END_ELEMENT){ return xmlStrdup(BAD_CAST ""); } /* skip all other non-text */ if (type != XML_READER_TYPE_TEXT) continue; text = xmlTextReaderValue(reader); begin_ptr = text; while ((begin_ptr[0] != 0) && (isspace(begin_ptr[0]))) begin_ptr++; if (begin_ptr[0] == 0) { xmlFree(text); return xmlStrdup(BAD_CAST ""); } end_ptr = begin_ptr; while ((end_ptr[0] != 0) && (!isspace(end_ptr[0]))) end_ptr++; end_ptr[0] = 0; ret = xmlStrdup(begin_ptr); xmlFree(text); return ret; } rrd_set_error("file ended while looking for text"); return NULL; } /* get_xml_text */
/* reader:value() */ static int xmlreader_value(lua_State *L) { xmlreader xr = check_xmlreader(L, 1); char *value = (char*)xmlTextReaderValue(xr); if (value) { lua_pushstring(L, value); xmlFree(value); return 1; } else { lua_pushnil(L); lua_pushstring(L, "not available"); return 2; } }
int main (void) { xmlTextReaderPtr xml = xmlReaderForFd (STDIN_FILENO, "", NULL, 0); while (xmlTextReaderRead (xml)) { char *name = (char *) BAD_CAST xmlTextReaderName (xml); if (xmlTextReaderNodeType (xml) == XML_READER_TYPE_ELEMENT && strcasecmp (name, "text") == 0) { while (xmlTextReaderRead (xml) && // memory leak : xmlStrcmp (xmlTextReaderName (xml), BAD_CAST "#text") != 0) {} printf ("%s\n", xmlTextReaderValue (xml)); } } }
TileMapParseStatus TileMap_parse_map(xmlTextReaderPtr reader, Engine *engine, TileMap *map) { TileMapParseStatus status = TILEMAP_PARSE_OK; xmlChar *name = xmlTextReaderName(reader); if (!(streq(name, "map") && xmlTextReaderNodeType(reader) == XML_ELEMENT_NODE)) { return TILEMAP_PARSE_INVALID_FORMAT; } while (xmlTextReaderMoveToNextAttribute(reader)) { xmlChar *attrName = xmlTextReaderName(reader); xmlChar *attrVal = xmlTextReaderValue(reader); if (streq(attrName, "orientation")) { if (!streq(attrVal, "orthogonal")) { return TILEMAP_PARSE_INVALID_ORIENTATION; } } else if (streq(attrName, "width")) { map->cols = atoi((const char *)attrVal); } else if (streq(attrName, "height")) { map->rows = atoi((const char *)attrVal); } else if (streq(attrName, "tilewidth")) { map->tile_size.w = atoi((const char *)attrVal); } else if (streq(attrName, "tileheight")) { map->tile_size.h = atoi((const char *)attrVal); } } while (xmlTextReaderRead(reader)) { xmlChar *childName = xmlTextReaderName(reader); if (xmlTextReaderNodeType(reader) == XML_ELEMENT_DECL && streq(childName, "map")) { break; } else if (streq(childName, "tileset")) { Tileset *tileset = NULL; status = TileMap_parse_tileset(reader, engine, map, &tileset); if (status != TILEMAP_PARSE_OK) return status; DArray_push(map->tilesets, tileset); } else if (streq(childName, "layer")) { TileMapLayer *layer = NULL; status = TileMap_parse_layer(reader, map, &layer); if (status != TILEMAP_PARSE_OK) return status; DArray_push(map->layers, layer); } } return status; }
char *oscap_element_string_copy(xmlTextReaderPtr reader) { int t; if (xmlTextReaderIsEmptyElement(reader)) return NULL; t = xmlTextReaderNodeType(reader); if (t == XML_ELEMENT_NODE || t == XML_ATTRIBUTE_NODE) xmlTextReaderRead(reader); if (xmlTextReaderHasValue(reader)) return (char *)xmlTextReaderValue(reader); else return (char *) calloc(1,1); }
void daeLIBXMLPlugin::readValue( daeElement *element, xmlTextReaderPtr reader ) { if ( element->getMeta()->getValueAttribute() == NULL ) { char err[256]; memset( err, 0, 256 ); #if LIBXML_VERSION >= 20620 sprintf(err,"The DOM was unable to set a value for element of type %s at line %d\nProbably a schema violation.\n", element->getTypeName() ,xmlTextReaderGetParserLineNumber(reader)); #else sprintf(err,"The DOM was unable to set a value for element of type %s at line %d\nProbably a schema violation.\n", element->getTypeName() ); #endif daeErrorHandler::get()->handleWarning( err ); } else if(element->getMeta()->getUsesStringContents()) { // String is used as one piece element->getMeta()->getValueAttribute()->set(element,(const daeString)xmlTextReaderConstValue(reader)); } else { // String needs to be broken up into whitespace seperated items. The "set" methods for numbers are smart enough to // grab just the first number in a string, but the ones for string lists require a null terminator between each // string. If this could be fixed we could avoid a copy and memory allocation by using xmlTextReaderConstValue(reader) xmlChar* value = xmlTextReaderValue(reader); daeChar* current = (daeChar *)value; while(*current != 0) { // !!!GAC NEEDS TO BE CHANGED to use XML standard whitespace parsing // Skip leading whitespace while(*current == ' ' || *current == '\r' || *current == '\n' || *current == '\t') current++; if(*current != 0) { daeChar* start=current; // Find end of string and insert a zero terminator while(*current != ' ' && *current != '\r' && *current != '\n' && *current != '\t' && *current != 0) current++; if(*current != 0) { *current = 0; current++; } element->getMeta()->getValueAttribute()->set(element,start); // eat the characters we just read (would be nice if set returned characters used. } } xmlFree(value); } int ret = xmlTextReaderRead(reader); assert(ret==1); }
// 1つのノードを処理する void processNode(xmlTextReaderPtr reader) { static parsingStatus state = STATE_NONE; xmlElementType nodeType; xmlChar *name, *value; // ノード情報の取得 nodeType = xmlTextReaderNodeType(reader); // ノードタイプ name = xmlTextReaderName(reader); // ノード名 if (!name) name = xmlStrdup(BAD_CAST "---"); if (nodeType == XML_READER_TYPE_ELEMENT) { // 開始 if ( xmlStrcmp(name, BAD_CAST "item") == 0 ) { state = STATE_ITEM; } else if ( xmlStrcmp(name, BAD_CAST "price") == 0 ) { state = STATE_PRICE; } } else if (nodeType == XML_READER_TYPE_END_ELEMENT) { // 終了 if ( xmlStrcmp(name, BAD_CAST "fruit") == 0 ) { printf("-----------------------\n"); } state = STATE_NONE; } else if (nodeType == XML_READER_TYPE_TEXT) { // テキスト // テキストを取得する value = xmlTextReaderValue(reader); if (!value) value = xmlStrdup(BAD_CAST "---"); if ( state == STATE_ITEM ) { printf("品名: %s\n", value); } else if ( state == STATE_PRICE ) { printf("価格: %s円\n", value); } xmlFree(value); } xmlFree(name); }
static xmlChar *xmlTextReaderReadEntireNodeValue(xmlTextReaderPtr reader) { xmlChar *buffer = calloc(1, sizeof(xmlChar)); const xmlChar *snippet; int status; if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ATTRIBUTE) { return xmlTextReaderValue(reader); } else if (xmlTextReaderIsEmptyElement(reader) == 0) { status = xmlTextReaderRead(reader); while (status && (xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT || xmlTextReaderNodeType(reader) == XML_READER_TYPE_CDATA || xmlTextReaderNodeType(reader) == XML_READER_TYPE_ENTITY_REFERENCE)) { snippet = xmlTextReaderConstValue(reader); buffer = realloc(buffer, (xmlStrlen(buffer) + xmlStrlen(snippet) + 1) * sizeof(xmlChar)); xmlStrcat(buffer, snippet); status = xmlTextReaderRead(reader); } } return buffer; }
void Table::RTTraiteItem(int & etat, SetOfInt & tmpSetOfInt) { // on recupere le reader xmlTextReaderPtr reader = getXmlReader(); // on doit r�up�er le contenu de la balise Item if (xmlTextReaderNodeType(reader) == contenuBalise) { //char * tmpValue = (char *)(xmlTextReaderValue(reader)); string tmpValue = (char *)(xmlTextReaderValue(reader)); int eltToInsert = getItemByName(tmpValue); tmpSetOfInt.insert(eltToInsert); etat = RTTuple; } // on réinitialise le reader setXmlReader(reader); }
void Table::ICTraiteItem(int & etat, int & cpt) { // on recupere le reader xmlTextReaderPtr reader = getXmlReader(); // on doit recuperer le contenu de la balise Item if (xmlTextReaderNodeType(reader) == contenuBalise) { //char * tmpValue = (char *)(xmlTextReaderValue(reader)); string tmpValue = (char *)(xmlTextReaderValue(reader)); mapping[tmpValue] = cpt; cpt++; etat = ICListItems; } // on réinitialise le reader setXmlReader(reader); }
/* * Parse the configuration file's abstract metadata element */ static void ows_parse_config_abstract(ows * o, xmlTextReaderPtr r) { xmlChar *v; assert(r); assert(o); assert(o->metadata); /* FIXME should use XmlTextReader expand on metadata parent */ xmlTextReaderRead(r); v = xmlTextReaderValue(r); if (v) { o->metadata->abstract = buffer_init(); buffer_add_str(o->metadata->abstract, (char *) v); xmlFree(v); } }
std::string XmlReader::ReadElementValue() { if(xmlTextReaderNodeType(mImpl) != XML_READER_TYPE_ELEMENT) { throw Exception("Element expected"); } Advance(); std::string ret; int type = xmlTextReaderNodeType(mImpl); switch(type) { case XML_READER_TYPE_END_ELEMENT: break; case XML_READER_TYPE_TEXT: { const char *value = (const char*)xmlTextReaderValue(mImpl); if(!value) { throw Exception("Couldn't read xml"); } ret = value; Advance(); } break; default: throw Exception("Text node expected"); } if(xmlTextReaderNodeType(mImpl) != XML_READER_TYPE_END_ELEMENT) { throw Exception("Unexpected node. End element expected"); } Advance(); return ret; }
static void FetchAttributes(xmlTextReaderPtr reader,t_ctxt *ctxt) { int i; int attrCount = xmlTextReaderAttributeCount(reader); //printf("fetch xml attributes %d\n",attrCount); ctxt->atcount = 0; for (i = 0; i < attrCount && i < XOML_MAX_ATTR ; i++) { xmlChar *aqname = NULL; xmlChar *avalue = NULL; xmlTextReaderMoveToAttributeNo(reader,i); aqname = xmlTextReaderName(reader); avalue = xmlTextReaderValue(reader); ctxt->atname[ctxt->atcount] = (char *)aqname; ctxt->atvalue[ctxt->atcount] = (char *)avalue; ctxt->atcount++; } }
static int _oval_result_test_binding_parse(xmlTextReaderPtr reader, struct oval_parser_context *context, void **args) { int return_code = 0; xmlChar *variable_id = xmlTextReaderGetAttribute(reader, BAD_CAST "variable_id"); struct oval_syschar_model *syschar_model = oval_result_system_get_syschar_model(SYSTEM); struct oval_definition_model *definition_model = oval_syschar_model_get_definition_model(syschar_model); struct oval_variable *variable = oval_definition_model_get_new_variable (definition_model, (char *)variable_id, OVAL_VARIABLE_UNKNOWN); xmlChar *value = xmlTextReaderValue(reader); struct oval_variable_binding *binding = oval_variable_binding_new(variable, oscap_strdup((char *) value)); oval_result_test_add_binding(TEST, binding); xmlFree(value); xmlFree(variable_id); return return_code; }