本文整理汇总了C++中xmlTextReaderName函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlTextReaderName函数的具体用法?C++ xmlTextReaderName怎么用?C++ xmlTextReaderName使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlTextReaderName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TileMapLayer_parse_data
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;
}
示例2: _exml_read
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;
}
示例3: main
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));
}
}
}
示例4: getXmlReader
void Table::RTTraiteTuple(int & etat, SetOfInt & tmpSetOfInt)
{
// on recupere le reader
xmlTextReaderPtr reader = getXmlReader();
if ((xmlTextReaderNodeType(reader) == baliseOuvrante) && (xmlStrcmp(xmlTextReaderName(reader), xmlCharStrdup("Item")) == 0))
etat = RTItem;
if ((xmlTextReaderNodeType(reader) == baliseFermante) && (xmlStrcmp(xmlTextReaderName(reader), xmlCharStrdup("Tuple")) == 0))
etat = RTFin;
// on réinitialise le reader
setXmlReader(reader);
}
示例5: TileMap_parse_map
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;
}
示例6: ows_parse_config_pg
/*
* 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);
}
示例7: processNode
void processNode( xmlTextReaderPtr reader, node *nodeTable) {
int index ;
const xmlChar *name, *value;
name = xmlTextReaderConstName(reader);
if (name == NULL)
name = BAD_CAST "--";
index = 0 ;
while ( xmlTextReaderRead( reader) == 1) {
switch ( xmlTextReaderNodeType(reader)) {
case XML_READER_TYPE_ELEMENT :
if ( strcmp((char *) xmlTextReaderName( reader), "groupobject") == 0) {
strcpy( nodeTable[index].name, (char *) xmlTextReaderGetAttribute( reader, (xmlChar *) "name")) ;
strcpy( nodeTable[index].alias, (char *) xmlTextReaderGetAttribute( reader, (xmlChar *) "alias")) ;
nodeTable[index].knxGroupAddr = atoi( (char *) xmlTextReaderGetAttribute( reader, (xmlChar *) "knxGroupAddr")) ;
nodeTable[index].type = lookupDPT( (char *) xmlTextReaderGetAttribute( reader, (xmlChar *) "dpt")) ;
// printf( "Element node\n") ;
// printf( " Id............: %s \n", (char *) xmlTextReaderGetAttribute( reader, (xmlChar *) "id")) ;
// printf( " Name..........: '%s' \n", (char *) xmlTextReaderGetAttribute( reader, (xmlChar *) "name")) ;
// printf( " DPT...........: %s(%d) \n", (char *) xmlTextReaderGetAttribute( reader, (xmlChar *) "dpt"), nodeTable[index].type) ;
// printf( " Group addr....: %s \n", (char *) xmlTextReaderGetAttribute( reader, (xmlChar *) "groupAddr")) ;
// printf( " Trigger only..: %s \n", (char *) xmlTextReaderGetAttribute( reader, (xmlChar *) "trigger")) ;
index++ ;
}
break ;
}
}
}
示例8: processNode
/**
* 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);
}
}
}
示例9: xmlTextReaderName
string BEXMLTextReader::name()
{
const xmlChar * node_name = xmlTextReaderName ( reader );
string name = (const char *)node_name;
xmlFree ( (xmlChar *)node_name );
return name;
}
示例10: processNode
static void processNode(xmlTextReaderPtr reader, struct osmdata_t *osmdata) {
xmlChar *name;
name = xmlTextReaderName(reader);
if (name == NULL)
name = xmlStrdup(BAD_CAST "--");
switch(xmlTextReaderNodeType(reader)) {
case XML_READER_TYPE_ELEMENT:
StartElement(reader, name, osmdata);
if (xmlTextReaderIsEmptyElement(reader))
EndElement(name, osmdata); /* No end_element for self closing tags! */
break;
case XML_READER_TYPE_END_ELEMENT:
EndElement(name, osmdata);
break;
case XML_READER_TYPE_SIGNIFICANT_WHITESPACE:
/* Ignore */
break;
default:
fprintf(stderr, "Unknown node type %d\n", xmlTextReaderNodeType(reader));
break;
}
xmlFree(name);
}
示例11: getNextNode
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;
}
示例12: expect_element_end
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 */
示例13: getElementContent
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;
}
示例14: parse_ac_fp
//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);
}
}
}
示例15: parse_ac_af
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);
}
}
}