您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xmlParseFile函数代码示例

51自学网 2021-06-03 11:46:22
  C++
这篇教程C++ xmlParseFile函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中xmlParseFile函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlParseFile函数的具体用法?C++ xmlParseFile怎么用?C++ xmlParseFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了xmlParseFile函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv){    xmlDocPtr doc;    char buf[1024];    FILE *f;    size_t l;    printf("- From file/n");    doc = xmlParseFile(argv[1]);    printf("encoding: %s/ncharset: %d/n",           doc->encoding, doc->charset);    xmlFreeDoc(doc);    f = fopen(argv[1], "r");    l = fread(buf, 1, 1024, f);        printf("- From memory/n");    doc = xmlParseMemory(buf, l);    printf("encoding: %s/ncharset: %d/n",           doc->encoding, doc->charset);    xmlFreeDoc(doc);    return 0;}
开发者ID:myth9499,项目名称:ups,代码行数:24,


示例2: parseDoc

Map* parseDoc(char* filename){	xmlDocPtr doc;	xmlNodePtr root_element;	doc = xmlParseFile(filename);	if (doc == NULL) {		fprintf(stderr, "Failed to parse %s/n", filename);		return NULL;	}	root_element = xmlDocGetRootElement(doc);	if (root_element == NULL){		fprintf(stderr, "empty document/n");		xmlFreeDoc(doc);		return NULL;	}	Map* map = malloc(sizeof(Map));	map = parseElements(doc, root_element);	xmlFreeDoc(doc);	return map;}
开发者ID:PierrickJACQUETTE,项目名称:CPROJ,代码行数:24,


示例3: ParseFlowListTag

short ParseFlowListTag( char *fname, void **list ){	xmlDocPtr doc = NULL;	xmlNodePtr current;	FLOWCOMP rootComp;	short result = -1;	if ( list == NULL ) goto Err1;	if ( (doc = xmlParseFile( fname )) == NULL ) goto Err1;	current = xmlDocGetRootElement( doc );	if ( (current == NULL) || xmlStrcmp( current->name, (const xmlChar *)"maintenance-resource" ) ){		goto Err2;	}	memset( &rootComp, 0, sizeof(FLOWCOMP) );	current = current->xmlChildrenNode;	while ( current != NULL ){		if ( (!xmlStrcmp( current->name, (const xmlChar *)"flowlist" )) ){			if ( ParseFlowTag( current->xmlChildrenNode, &rootComp ) != 0 ) goto Err2;			break;		}		current = current->next;	}	*list = rootComp.next;	result = 0;EXIT:	xmlFreeDoc( doc );	return result;Err2:	FreeFlowCompList( rootComp.next );Err1:	goto EXIT;}
开发者ID:spremi,项目名称:cnijfilter-source-3.80,代码行数:36,


示例4: interpret_oglerc

int interpret_oglerc(char *filename){  xmlDocPtr doc;  xmlNodePtr cur;      doc = xmlParseFile(filename);  if(doc != NULL) {    cur = xmlDocGetRootElement(doc);     while(cur != NULL) {            if(!xmlIsBlankNode(cur)) {	if(!strcmp("ogle_conf", cur->name)) {	  interpret_ogle_conf(doc, cur);	}      }      cur = cur->next;    }        xmlFreeDoc(doc);    return 0;  } else {    WARNING("Couldn't load config file/n");    return -1;  }}
开发者ID:BackupTheBerlios,项目名称:ogle,代码行数:36,


示例5: xmlParseFile

bool CZBConfiguration::ReadModelsFile(const char *_file){	std::cout << "parsing models file " << std::string(_file) << std::endl;	doc = xmlParseFile(_file);	if(doc==NULL)	{		//std::cerr << "XML file " << std::string(_file) << " empty" << std::endl;		return false;	}	root_element = xmlDocGetRootElement(doc);	for( xmlNode *level_1 = root_element->children ; level_1 != NULL ; level_1 = level_1->next)	{		// end_devices_models level		if(!xmlStrcmp(level_1->name,(const char *)"end_devices_model"))			for( xmlNode *level_2 = level_1->children ; level_2 != NULL; level_2 = level_2->next)			{				// model level				if(!xmlStrcmp(level_2->name,(const char *)"model"))					for( xmlNode *level_3 = level2->children; level_3 != NULL ; level_3 = level_3->next )					{						// channel level					}				if(!xmlStrcmp(level_2->name,(const char *)"models_version"))				{								}			}	}	return true;	}
开发者ID:jpcordovae,项目名称:ZigBeeDispatcher,代码行数:36,


示例6: loadCfg

/***	loadCfg: This function loads cfg file to RAM memory using libxml API functions	xmlfile: Cfg's file name*/void loadCfg(char *xmlfile){    xmlDoc *doc = NULL;    xmlNode *root_element = NULL;    LIBXML_TEST_VERSION    doc = xmlParseFile(xmlfile);    if (doc == NULL) {        printf("error: could not parse file file.xml/n");	exit(1);    }    root_element = xmlDocGetRootElement(doc);	puts("carregando nodos/n");    loadNodes(getElement(root_element, "nodes"));	puts("construindo arestas/n");    buildGraphFromEdges(getElement(root_element, "edges"));    xmlFreeDoc(doc);    xmlCleanupParser();}
开发者ID:frcoelho,项目名称:pesti,代码行数:28,


示例7: findTags

static voidfindTags (void){	xmlNode *i;	xmlDocPtr doc = xmlParseFile(getInputFileName());	xmlNode *root;	if (doc == NULL) {		g_warning ("could not parse file");	}	root = xmlDocGetRootElement(doc);	for (i = root->children; i; i = i->next)	{		xmlNode *j;		if (!i->name)			continue;		if (strcmp ((const char*)i->name, "namespace") !=0)			continue;		for (j = i->children; j; j = j->next)		{			makeTags (j, NULL);		}	}}
开发者ID:VujinovM,项目名称:anjuta,代码行数:24,


示例8: xmlParseFile

	int File::loadXML(const char *filename, Context *ctx) {		xmlDocPtr doc = NULL;		xmlNodePtr root;		int length;		doc = xmlParseFile(filename);		if (!doc) {			fprintf(stderr, "could not parse XML/n");			return false;		}		root = doc->xmlRootNode;		length = setXML(root, ctx);		xmlFreeDoc(doc);		return length;	fail:		if (doc) {			xmlFreeDoc(doc);		}		return 0;	}
开发者ID:BizioMetal,项目名称:swfmill,代码行数:24,


示例9: load_player_objects_from_file

boolload_player_objects_from_file(struct creature *ch, const char *path){    int axs = access(path, W_OK);    if (axs != 0) {        if (errno != ENOENT) {            errlog("Unable to open xml equipment file '%s': %s",                path, strerror(errno));            return -1;        } else {            return 1;           // normal no eq file        }    }    xmlDocPtr doc = xmlParseFile(path);    if (!doc) {        errlog("XML parse error while loading %s", path);        return -1;    }    xmlNodePtr root = xmlDocGetRootElement(doc);    if (!root) {        xmlFreeDoc(doc);        errlog("XML file %s is empty", path);        return 1;    }    for (xmlNodePtr node = root->xmlChildrenNode; node; node = node->next) {        if (xmlMatches(node->name, "object"))            (void)load_object_from_xml(NULL, ch, NULL, node);    }    xmlFreeDoc(doc);    return 0;}
开发者ID:TempusMUD,项目名称:Tempuscode,代码行数:36,


示例10: xmlCleanupParser

Manifest *create_manifest(const gchar *manifest_file, const unsigned int flags, const gchar *container_filter, const gchar *component_filter){    xmlDocPtr doc;    xmlNodePtr node_root;    Manifest *manifest;    /* Parse the XML document */    if((doc = xmlParseFile(manifest_file)) == NULL)    {        g_printerr("Error with parsing the manifest XML file!/n");        xmlCleanupParser();        return NULL;    }    /* Retrieve root element */    node_root = xmlDocGetRootElement(doc);    if(node_root == NULL)    {        g_printerr("The manifest XML file is empty!/n");        xmlFreeDoc(doc);        xmlCleanupParser();        return NULL;    }    /* Parse manifest */    manifest = parse_manifest(node_root, flags, container_filter, component_filter);    /* Cleanup */    xmlFreeDoc(doc);    xmlCleanupParser();    /* Return manifest */    return manifest;}
开发者ID:svanderburg,项目名称:disnix,代码行数:36,


示例11: gpa_printer_new_from_file

/** * gpa_printer_new_from_file: * @file:  *  * Load a new printer from @filename, file should contain a XML description *  * Return Value:  **/static GPANode *gpa_printer_new_from_file (const gchar *file){	GPANode *printer = NULL;	xmlDocPtr doc;	xmlNodePtr node;	doc = xmlParseFile (file);	if (!doc) {		g_warning ("Could not parse %s/n", file);		return NULL;	}	node = doc->xmlRootNode;	printer = gpa_printer_new_from_tree (node);	xmlFreeDoc (doc);	if (!printer || !gpa_node_verify (printer)) {		g_warning ("Could not load printer from %s", file);		printer = NULL;	}		return printer;}
开发者ID:GNOME,项目名称:libgnomeprint,代码行数:32,


示例12: _currentGameDescription

GameManager::GameManager () :	_currentGameDescription(0), _enginePath(GlobalRegistry().get(RKEY_ENGINE_PATH)), _cleanedEnginePath(			DirectoryCleaned(_enginePath)), _emptyString(""){	GlobalRegistry().addKeyObserver(this, RKEY_ENGINE_PATH);	// greebo: Register this class in the preference system so that the constructPreferencePage() gets called.	GlobalPreferenceSystem().addConstructor(this);	// TODO Remove this and read the game.xml data from the xmlregistry, too	std::string strGameFilename = Environment::Instance().getAppPath() + "game.xml";	xmlDocPtr pDoc = xmlParseFile(strGameFilename.c_str());	if (pDoc) {		_currentGameDescription = new GameDescription(pDoc, strGameFilename);		// Import this information into the registry		//GlobalRegistry().importFromFile(strGameFilename, "");		xmlFreeDoc(pDoc);	} else {		gtkutil::errorDialog(_("XML parser failed to parse game.xml"));	}	initialise();}
开发者ID:AresAndy,项目名称:ufoai,代码行数:24,


示例13: config_parse_file

int config_parse_file(const char *filename, ice_config_t *configuration){    xmlDocPtr doc;    xmlNodePtr node;    if (filename == NULL || strcmp(filename, "") == 0) return CONFIG_EINSANE;        xmlInitParser();    doc = xmlParseFile(filename);    if (doc == NULL) {        return CONFIG_EPARSE;    }    node = xmlDocGetRootElement(doc);    if (node == NULL) {        xmlFreeDoc(doc);        xmlCleanupParser();        return CONFIG_ENOROOT;    }    if (strcmp(node->name, "icecast") != 0) {        xmlFreeDoc(doc);        xmlCleanupParser();        return CONFIG_EBADROOT;    }    config_init_configuration(configuration);    configuration->config_filename = (char *)strdup(filename);    _parse_root(doc, node->xmlChildrenNode, configuration);    xmlFreeDoc(doc);    return 0;}
开发者ID:kitsune-dsu,项目名称:kitsune-icecast,代码行数:36,


示例14: readinput_init

void readinput_init(){  if(myid == 0) {  doc = xmlParseFile("input");  if (doc == NULL ) {    fprintf(stderr,"input file not parsed successfully. /n");#if defined(HAVE_MPI)    MPI_Finalize();#endif    exit(0);  }  cur = xmlDocGetRootElement(doc);  if (cur == NULL) {    fprintf(stderr,"input file is empty/n");    xmlFreeDoc(doc);#if defined(HAVE_MPI)    MPI_Finalize();#endif    exit(0);  }}}
开发者ID:albertocbarrigon,项目名称:maxdft,代码行数:24,


示例15: create_file

void create_file(char *to, char *from, char *msg){	int rc;	xmlTextWriterPtr writer;	xmlDocPtr doc;	xmlNodePtr node, root;	xmlChar *tmp;	if(doc = xmlParseFile(to)){		root = xmlDocGetRootElement(doc);		xmlNodePtr pNode = xmlNewNode(0, (xmlChar*)"mes");		//xmlSetProp(pNode, (const xmlChar*) "id", (const xmlChar*) "val");		xmlSetProp(pNode, (const xmlChar*) "from", (const xmlChar*) from);		xmlNodeSetContent(pNode, (xmlChar*)msg);		xmlAddChild(root, pNode);		xmlSaveFileEnc(to, doc, MY_ENCODING);		xmlFreeDoc(doc);	}else{		doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);		node = xmlNewDocNode(doc, NULL, BAD_CAST "inbox", NULL);		xmlDocSetRootElement(doc, node);		writer = xmlNewTextWriterTree(doc, node, 0);		rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL);		rc = xmlTextWriterStartElement(writer, BAD_CAST "mes");		//rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "id", BAD_CAST "1");		rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "from", BAD_CAST from);		rc = xmlTextWriterEndAttribute(writer);		rc = xmlTextWriterWriteString(writer, (const xmlChar*) msg);		rc = xmlTextWriterEndElement(writer);		rc = xmlTextWriterEndDocument(writer);		xmlFreeTextWriter(writer);		xmlSaveFileEnc(to, doc, MY_ENCODING);		xmlFreeDoc(doc);	}}
开发者ID:h31,项目名称:NetworksCourseBackup,代码行数:36,


示例16: xmlParseFile

/** * * @param fileName Full path to the XML file to be read * @return true if the file could be read and parsed. Else false. */bool XMLConfParser::readFile(std::string fileName){	if(fDoc != NULL) closeFile();	fDoc = xmlParseFile(fileName.data());	if (fDoc == NULL ) {		std::stringstream ss;		xmlErrorPtr errPtr = xmlGetLastError();		ss << "Document not parsed successfully." << std::endl;		ss << "File: " << errPtr->file << " at (l:";		ss << errPtr->line << ", c:" << errPtr->int2;		ss << "): " << errPtr->message << std::endl;		throw XMLConfParserFatalException(ss);		return false;	}	fRoot = xmlDocGetRootElement(fDoc);	if (fRoot == NULL) {		throw XMLConfParserFatalException("Document is empty.");		return false;	}	return true;}
开发者ID:nlurkin,项目名称:XMLPreProcessor,代码行数:29,


示例17: xmlParseFile

bool Vocations::loadFromXml(){	xmlDocPtr doc = xmlParseFile(getFilePath(FILE_TYPE_XML,"vocations.xml").c_str());	if(!doc)	{		std::clog << "[Warning - Vocations::loadFromXml] Cannot load vocations file." << std::endl;		std::clog << getLastXMLError() << std::endl;		return false;	}	xmlNodePtr p, root = xmlDocGetRootElement(doc);	if(xmlStrcmp(root->name,(const xmlChar*)"vocations"))	{		std::clog << "[Error - Vocations::loadFromXml] Malformed vocations file." << std::endl;		xmlFreeDoc(doc);		return false;	}	for(p = root->children; p; p = p->next)		parseVocationNode(p);	xmlFreeDoc(doc);	return true;}
开发者ID:tryller,项目名称:otserv,代码行数:24,


示例18: xmlParseFile

GRSTgaclAcl *GRSTxacmlAclLoadFile(char *filename){  xmlDocPtr   doc;  xmlNodePtr  cur;  GRSTgaclAcl    *acl;  doc = xmlParseFile(filename);  if (doc == NULL) return NULL;  cur = xmlDocGetRootElement(doc);  if (cur == NULL) return NULL;  if (!xmlStrcmp(cur->name, (const xmlChar *) "Policy")) { acl=GRSTxacmlAclParse(doc, cur, acl);}  else if (!xmlStrcmp(cur->name, (const xmlChar *) "gacl")) {acl=GRSTgaclAclParse(doc, cur, acl);}  else /* ACL format not recognised */    {      xmlFreeDoc(doc);      free(cur);      return NULL;    }  xmlFreeDoc(doc);  return acl;}
开发者ID:CESNET,项目名称:gridsite,代码行数:24,


示例19: xmlParseFile

bool Vocations::loadFromXml(){	std::string filename = "data/XML/vocations.xml";	xmlDocPtr doc = xmlParseFile(filename.c_str());	if (doc) {		xmlNodePtr root, p;		root = xmlDocGetRootElement(doc);		if (xmlStrcmp(root->name, (const xmlChar*)"vocations") != 0) {			xmlFreeDoc(doc);			return false;		}		p = root->children;		while (p) {			std::string str;			int32_t intVal;			if (xmlStrcmp(p->name, (const xmlChar*)"vocation") == 0) {				Vocation* voc = new Vocation();				uint32_t voc_id;				xmlNodePtr configNode;				if (readXMLInteger(p, "id", intVal)) {					float floatVal;					voc_id = intVal;					if (readXMLString(p, "name", str)) {						voc->name = str;					}					if (readXMLInteger(p, "clientid", intVal)) {						voc->clientId = intVal;					}					if (readXMLString(p, "description", str)) {						voc->description = str;					}					if (readXMLInteger(p, "gaincap", intVal)) {						voc->gainCap = intVal;					}					if (readXMLInteger(p, "gainhp", intVal)) {						voc->gainHP = intVal;					}					if (readXMLInteger(p, "gainmana", intVal)) {						voc->gainMana = intVal;					}					if (readXMLInteger(p, "gainhpticks", intVal)) {						voc->gainHealthTicks = intVal;					}					if (readXMLInteger(p, "gainhpamount", intVal)) {						voc->gainHealthAmount = intVal;					}					if (readXMLInteger(p, "gainmanaticks", intVal)) {						voc->gainManaTicks = intVal;					}					if (readXMLInteger(p, "gainmanaamount", intVal)) {						voc->gainManaAmount = intVal;					}					if (readXMLFloat(p, "manamultiplier", floatVal)) {						voc->manaMultiplier = floatVal;					}					if (readXMLInteger(p, "attackspeed", intVal)) {						voc->attackSpeed = intVal;					}					if (readXMLInteger(p, "basespeed", intVal)) {						voc->baseSpeed = intVal;					}					if (readXMLInteger(p, "soulmax", intVal)) {						voc->soulMax = intVal;					}					if (readXMLInteger(p, "gainsoulticks", intVal)) {						voc->gainSoulTicks = intVal;					}					if (readXMLInteger(p, "fromvoc", intVal)) {						voc->fromVocation = intVal;					}					configNode = p->children;					while (configNode) {						if (xmlStrcmp(configNode->name, (const xmlChar*)"skill") == 0) {							uint32_t skill_id;//.........这里部分代码省略.........
开发者ID:24312108k,项目名称:forgottenserver,代码行数:101,


示例20: apply_xslt_stylesheet

// Processes input XML file (e.g., instance metadata) into output XML file or string (e.g., for libvirt)// using XSL-T specification file (e.g., libvirt.xsl)static int apply_xslt_stylesheet (const char * xsltStylesheetPath, const char * inputXmlPath, const char * outputXmlPath, char * outputXmlBuffer, int outputXmlBufferSize){        int err = OK;        INIT();        xsltStylesheetPtr cur = xsltParseStylesheetFile ((const xmlChar *)xsltStylesheetPath);        if (cur) {                xmlDocPtr doc = xmlParseFile (inputXmlPath);                if (doc) {                        xsltTransformContextPtr ctxt = xsltNewTransformContext (cur, doc); // need context to get result                        xsltSetCtxtParseOptions (ctxt, 0); // TODO: do we want any XSL-T parsing options?                        xmlDocPtr res = xsltApplyStylesheetUser (cur, doc, NULL, NULL, NULL, ctxt); // applies XSLT to XML                        int applied_ok = ctxt->state==XSLT_STATE_OK; // errors are communicated via ctxt->state                        xsltFreeTransformContext (ctxt);                                                if (res && applied_ok) {                            // save to a file, if path was provied                            if (outputXmlPath!=NULL) {                                FILE * fp = fopen (outputXmlPath, "w");                                if (fp) {                                    int bytes = xsltSaveResultToFile (fp, res, cur);                                    if (bytes==-1) {                                        logprintfl (EUCAERROR, "ERROR: failed to save XML document to %s/n", outputXmlPath);                                        err = ERROR;                                    }                                    fclose (fp);                                } else {                                    logprintfl (EUCAERROR, "ERROR: failed to create file %s/n", outputXmlPath);                                    err = ERROR;                                }                                                            }                            // convert to an ASCII buffer, if such was provided                            if (err==OK && outputXmlBuffer!=NULL && outputXmlBufferSize > 0) {                                xmlChar * buf;                                int buf_size;                                if (xsltSaveResultToString (&buf, &buf_size, res, cur)==0) { // success                                    if (buf_size < outputXmlBufferSize) {                                        bzero (outputXmlBuffer, outputXmlBufferSize);                                        for (int i=0, j=0; i<buf_size; i++) {                                            char c = (char) buf [i];                                            if (c != '/n') // remove newlines                                                outputXmlBuffer [j++] = c;                                        }                                    } else {                                        logprintfl (EUCAERROR, "ERROR: XML string buffer is too small (%d > %d)/n", buf_size, outputXmlBufferSize);                                        err = ERROR;                                    }                                    xmlFree (buf);                                } else {                                    logprintfl (EUCAERROR, "ERROR: failed to save XML document to a string/n");                                    err = ERROR;                                }                            }                        } else {                            logprintfl (EUCAERROR, "ERROR: failed to apply stylesheet %s to %s/n", xsltStylesheetPath, inputXmlPath);                            err = ERROR;                        }                        if (res!=NULL) xmlFreeDoc(res);                        xmlFreeDoc(doc);                } else {                        logprintfl (EUCAERROR, "ERROR: failed to parse XML document %s/n", inputXmlPath);                        err = ERROR;                }                xsltFreeStylesheet(cur);        } else {                logprintfl (EUCAERROR, "ERROR: failed to open and parse XSL-T stylesheet file %s/n", xsltStylesheetPath);                err = ERROR;        }        return err;}
开发者ID:nelsonc,项目名称:eucalyptus,代码行数:75,


示例21: get_tone_set

static void get_tone_set(const char *tone_file, const char *set_id){    xmlDocPtr doc;    xmlNsPtr ns;    xmlNodePtr cur;#if 0    xmlValidCtxt valid;#endif    xmlChar *x;    ns = NULL;        xmlKeepBlanksDefault(0);    xmlCleanupParser();    doc = xmlParseFile(tone_file);    if (doc == NULL)    {        fprintf(stderr, "No document/n");        exit(2);    }    /*endif*/    xmlXIncludeProcess(doc);#if 0    if (!xmlValidateDocument(&valid, doc))    {        fprintf(stderr, "Invalid document/n");        exit(2);    }    /*endif*/#endif    /* Check the document is of the right kind */    if ((cur = xmlDocGetRootElement(doc)) == NULL)    {        fprintf(stderr, "Empty document/n");        xmlFreeDoc(doc);        exit(2);    }    /*endif*/    if (xmlStrcmp(cur->name, (const xmlChar *) "global-tones"))    {        fprintf(stderr, "Document of the wrong type, root node != global-tones");        xmlFreeDoc(doc);        exit(2);    }    /*endif*/    cur = cur->xmlChildrenNode;    while (cur  &&  xmlIsBlankNode(cur))        cur = cur->next;    /*endwhile*/    if (cur == NULL)        exit(2);    /*endif*/    while (cur)    {        if (xmlStrcmp(cur->name, (const xmlChar *) "tone-set") == 0)        {            if ((x = xmlGetProp(cur, (const xmlChar *) "uncode")))            {                if (strcmp((char *) x, set_id) == 0)                    parse_tone_set(doc, ns, cur);                /*endif*/                xmlFree(x);            }            /*endif*/        }        /*endif*/        cur = cur->next;    }    /*endwhile*/    xmlFreeDoc(doc);}
开发者ID:RodrigoNieves,项目名称:FreeSWITCH,代码行数:70,


示例22: xmlParseFile

bool Traces::parse(const char *filename, int verbose) {  xmlDocPtr doc = xmlParseFile(filename);    if (doc == NULL) {    cout << "Error parsing the "<< filename << " !" << endl;    goto err;  }    xmlNodePtr node;    node = doc->children;     XMLASSERT(node->type == XML_ELEMENT_NODE &&             !strcmp((const char*)node->name, "gltrace"));    { // parse tracelist    xmlNodePtr xmllist = get_child_element(node, "tracelist");         XMLASSERT(xmllist);        for(xmlNodePtr tracenode = xmllist->children; tracenode; tracenode = tracenode->next) {      if(tracenode->type == XML_TEXT_NODE) continue;       XMLASSERT(tracenode->type == XML_ELEMENT_NODE &&                 !strcmp((const char*)tracenode->name, "trace"));            const char *object = get_element_attribute(tracenode, "object");       const char *name = get_element_attribute(tracenode, "name");       XMLASSERT(object && name);      xmlNodePtr shot = get_child_element(tracenode, "shot");       XMLASSERT(shot);      const char *id_str = get_element_attribute(shot, "id");       XMLASSERT(id_str);       int id;       XMLASSERT(sscanf(id_str, "%d", &id) == 1);       while((int)tracelist.size() <= id) {        tracelist.push_back(TracedEvent());                 }      tracelist[id].name = name;      tracelist[id].obj = object;            }            if(verbose) printf("loaded %ld traces/n", tracelist.size());  }          { // load links          xmlNodePtr linklist = get_child_element(node, "linklist");    XMLASSERT(linklist);    for(xmlNodePtr linknode = linklist->children; linknode; linknode = linknode->next) {      if(linknode->type == XML_TEXT_NODE) continue;       Link link;            XMLASSERT(linknode->type == XML_ELEMENT_NODE &&                 !strcmp((const char*)linknode->name, "link"));            xmlNodePtr source = get_child_element(linknode, "source");      xmlNodePtr destination = get_child_element(linknode, "destination");      XMLASSERT(source && destination);             string sourcecol = get_element_attribute(source, "name");       string destcol = get_element_attribute(destination, "name");             XMLASSERT(sourcecol.size() && destcol.size());             link.source = sourcecol.substr(0, sourcecol.find(':'));      link.sourceport = sourcecol.substr(sourcecol.find(':') + 1);      link.dest = destcol.substr(0, destcol.find(':'));      link.destport = destcol.substr(destcol.find(':') + 1);      // printf("size %d %p/n", links.size(), &links[0]);      links.push_back(link);      // printf("osize %d %s/n", links.size(), links[0].source.c_str());    }    if(verbose)  printf("%ld links/n", links.size());  }    { // fill in nextEvents    for(int i = 0; i < tracelist.size(); i++) {      TracedEvent &ev = tracelist[i];      Link *waitBeginLink = NULL;       bool recorded = false;       for(int l = 0; l < links.size(); l++) {        Link & link = links[l];        if(link.source == ev.obj && link.sourceport == ev.name) {          int dest_ev = find_event(link.dest, link.destport);           ev.links.push_back(&link);          if(dest_ev >= 0) {            ev.nextEvents.push_back(dest_ev);             recorded = true;          }        }        if(link.source == ev.obj && link.sourceport == "waitBegin")          waitBeginLink = &link;        if(link.dest == ev.obj && link.destport == ev.name &&           link.destport != "waitEnd") {          ev.links.push_back(&link);          recorded = true;        }      }//.........这里部分代码省略.........
开发者ID:BlueBrain,项目名称:FlowVR,代码行数:101,


示例23: convert_metadata_file

static gbooleanconvert_metadata_file (const gchar *filename){	ConvertData *data;	xmlDocPtr doc;	xmlNodePtr cur;	if (!g_file_test (filename, G_FILE_TEST_EXISTS))		return FALSE;	doc = xmlParseFile (filename);	if (!doc) {		g_printerr ("Error loading metadata file %s/n", filename);		return FALSE;	}	cur = xmlDocGetRootElement (doc);	if (!cur) {		g_printerr ("Metadata file %s is empty/n", filename);		xmlFreeDoc (doc);		return TRUE;	}	if (xmlStrcmp (cur->name, (const xmlChar *) "metadata")) {		g_printerr ("File %s is not a valid atril metadata file/n", filename);		xmlFreeDoc (doc);		return FALSE;	}	data = g_new0 (ConvertData, 1);	data->doc = doc;	for (cur = cur->xmlChildrenNode; cur != NULL; cur = cur->next) {		xmlChar *uri;		DocItem *item;		if (xmlStrcmp (cur->name, (const xmlChar *)"document") != 0)			continue;		uri = xmlGetProp (cur, (const xmlChar *)"uri");		if (!uri)			continue;		item = g_new (DocItem, 1);		item->uri = uri;		item->cur = cur;		data->items = g_list_prepend (data->items, item);	}	if (!data->items) {		xmlFreeDoc (data->doc);		g_free (data);		return TRUE;	}	show_progress_dialog (data);	data->current = data->items;	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,			 (GSourceFunc)convert_file,			 data,			 (GDestroyNotify)convert_finish);	return TRUE;}
开发者ID:Achal-Aggarwal,项目名称:atril,代码行数:66,


示例24: settings_read

int settings_read(const char* path){    xmlDocPtr   doc;    xmlNodePtr  noderoot;    xmlNodePtr  node1;    xmlNodePtr  node2;    xmlChar*    prop;    msg_log(MSG_MESSAGE, "Reading global settings from: %s/n",path);    doc = xmlParseFile (path);    if (doc == NULL)    {        msg_log(MSG_ERROR, "Failed to parse %s/n", path);        return -1;    }    noderoot = xmlDocGetRootElement(doc);    if (noderoot == NULL)    {        msg_log(MSG_WARNING, "%s is empty/n", path);        xmlFreeDoc(doc);        return -1;    }    if (xmlStrcmp(noderoot->name, BAD_CAST "Petri-Foo-Settings") != 0)    {        msg_log(MSG_ERROR,                "%s is not a valid 'Petri-Foo-Settings' file/n", path);        xmlFreeDoc(doc);        return -1;    }    for (node1 = noderoot->children;         node1 != NULL;         node1 = node1->next)    {        if (node1->type != XML_ELEMENT_NODE)            continue;        for ( node2 = node1->children;            node2 != NULL;            node2 = node2->next)        {            int n;            if (xmlStrcmp(node2->name, BAD_CAST "property") == 0)            {                prop = BAD_CAST xmlGetProp(node2, BAD_CAST "name");                if (xmlStrcmp(prop, BAD_CAST "last-sample-directory") == 0)                {                    free(gbl_settings->last_sample_dir);                    gbl_settings->last_sample_dir =                        (char*) xmlGetProp(node2, BAD_CAST "value");                }                if (xmlStrcmp(prop, BAD_CAST "last-bank-directory") == 0)                {                    free(gbl_settings->last_bank_dir);                    gbl_settings->last_bank_dir =                        (char*) xmlGetProp(node2, BAD_CAST "value");                }                if (xmlStrcmp(prop, BAD_CAST "sliders-use-fans") == 0)                {                    phin_fan_slider_set_fans_active(                        xmlstr_to_gboolean(xmlGetProp(node2,                                                    BAD_CAST "value")));                }                if (xmlStrcmp(prop, BAD_CAST "log-lines") == 0)                {                    xmlChar* vprop = xmlGetProp(node2, BAD_CAST "value");                    if (sscanf((const char*)vprop, "%d", &n) == 1)                        gbl_settings->log_lines = n;                }            }        }    }    return 0;}
开发者ID:licnep,项目名称:Petri-Foo,代码行数:86,


示例25: xml_parsing

/*---------------------------------------------------------------------------* * NAME: xml_parsing * DESC: Main xml parsing function *---------------------------------------------------------------------------*/void xml_parsing(config *conf) {  /* open the file using the libxml2 library */  debug(3, "xml parsing of the file: %s/n", conf->xml_filename);  conf->doc = xmlParseFile(conf->xml_filename);  if (conf->doc == NULL) {    error_("Document not parsed successfully!/n");    return;  }  verbose_("[*] parsing the file: %s/n", conf->xml_filename);  /* point on the root element of the tree */  conf->cur = xmlDocGetRootElement(conf->doc);  if (conf->cur == NULL) {    error_("Empty Document!/n");    xmlFreeDoc(conf->doc);    return;  }  /* check if the format seems to be PDML: ie root = pdml */  debug(3,"name of the root: %s/n", conf->cur->name);  if (xmlStrcmp(conf->cur->name, (const xmlChar *) "pdml")) {    error_("Document NOT a PDML file!/n");    xmlFreeDoc(conf->doc);    return;  }  /* start the autodafe's script language */  output_("/*--------------------------------------------------------------------------*/n");  output_(" * xml autodafe's parser v.%d.%d (c) Martin Vuagnoux - 2004-2006            */n", MAJOR_VERSION, MINOR_VERSION);  output_(" * auto-generated script using PDML (Packet Details Markup Language) source */n");  output_(" *--------------------------------------------------------------------------*//n/n");  /* the file is good, check for the packet entry (child) */  conf->cur = conf->cur->xmlChildrenNode;  while (conf->cur != NULL) {    if (!xmlStrcmp(conf->cur->name, (const xmlChar *) "packet")) {      debug(3, "packet field found/n");      /* open the block */      output_(AD_F_BLOCK_BEGIN"(/"packet_%d/");/n", conf->packet_counter);      /* parse the internal data of the packet block */      xml_parse_packet(conf);      /* close the block */      output_(AD_F_BLOCK_END"(/"packet_%d/");/n", conf->packet_counter);      /* client send/recv */      if ((conf->ip_pkt == conf->ip_client) && (conf->port_pkt == conf->port_client)) {	debug(3, "check client/n");	if (conf->transport_type == 1) {	  if (conf->invert == 0)	    output_(AD_F_SEND"(/"packet_%d/");  /* tcp *//n/n", conf->packet_counter);	  else	    output_(AD_F_RECV"(/"packet_%d/");  /* tcp *//n/n", conf->packet_counter);	}	else if (conf->transport_type == 2) {	  if (conf->invert == 0)	    output_(AD_F_SEND"(/"packet_%d/");  /* udp *//n/n", conf->packet_counter);	  else	    output_(AD_F_RECV"(/"packet_%d/");  /* udp *//n/n", conf->packet_counter);	}      }      /* server send/recv */      else if ((conf->ip_pkt == conf->ip_server) && (conf->port_pkt == conf->port_server)) {	debug(3, "check server/n");	if (conf->transport_type == 1) {	  if (conf->invert == 1)	    output_(AD_F_SEND"(/"packet_%d/");  /* tcp *//n/n", conf->packet_counter);	  else	    output_(AD_F_RECV"(/"packet_%d/");  /* tcp *//n/n", conf->packet_counter);	}	else if (conf->transport_type == 2) {	  if (conf->invert == 1)	    output_(AD_F_SEND"(/"packet_%d/");  /* udp *//n/n", conf->packet_counter);	  else	    output_(AD_F_RECV"(/"packet_%d/");  /* udp *//n/n", conf->packet_counter);	}      }      else {	error_("too much different packets?! Check your Ethereal logs!/n");	error_("client: ip->%d, port->%d/n", conf->ip_client, conf->port_client);	error_("server: ip->%d, port->%d/n", conf->ip_server, conf->port_server);	error_("packet: ip->%d, port->%d/n", conf->ip_pkt, conf->port_pkt);	exit(-1);      }      conf->packet_counter++;    }    conf->cur = conf->cur->next;  }  /* free */  xmlFreeDoc(conf->doc);//.........这里部分代码省略.........
开发者ID:wuyihao14,项目名称:autodafe,代码行数:101,


示例26: ReadGPX

int ReadGPX(const char* File, struct GPSTrack* Track){	/* Init the libxml library. Also checks version. */	LIBXML_TEST_VERSION	xmlDocPtr GPXData;		/* Read the GPX data from file. */	GPXData = xmlParseFile(File);	if (GPXData == NULL)	{		fprintf(stderr, _("Failed to parse GPX data from %s./n"), File);		return 0;	}	/* Now grab the "root" node. */	xmlNodePtr GPXRoot;	GPXRoot = xmlDocGetRootElement(GPXData);	if (GPXRoot == NULL)	{		fprintf(stderr, _("GPX file has no root. Not healthy./n"));		xmlFreeDoc(GPXData);		xmlCleanupParser();		return 0;	}	/* Check that this is indeed a GPX - the root node	 * should be "gpx". */	if (strcmp((const char *)GPXRoot->name, "gpx") == 0)	{		/* Ok, it is a GPX file. */	} else {		/* Not valid. */		fprintf(stderr, _("Invalid GPX file./n"));		xmlFreeDoc(GPXData);		xmlCleanupParser();		return 0;	}	/* Now comes the messy part... walking the tree to find	 * what we want.	 * I've chosen to do it with two functions, one of which	 * is recursive, rather than a clever inside-this-function	 * walk the tree thing.	 * 	 * We start by calling the recursive function to look for	 * <trkseg> tags, and then that function calls another	 * when it has found one... this sub function then	 * hauls out the <trkpt> tags with the actual data.	 * Messy, convoluted, but it seems to work... */	/* As to where to store the data? Again, its messy.	 * We maintain two global vars, FirstPoint and LastPoint.	 * FirstPoint points to the first GPSPoint done, and	 * LastPoint is the last point done, used for the next	 * point... we use this to build a singly-linked list. */	/* (I think I'll just be grateful for the work that libxml	 * puts in for me... imagine having to write an XML parser!	 * Nasty.) */	/* Before we go into this function, we also setlocale to "C".	 * The GPX def indicates that the decimal separator should be	 * ".", but certain locales specify otherwise. Which has caused issues.	 * So we set the locale for this function, and then revert it.	 */		FirstPoint = NULL;	LastPoint = NULL;		char* OldLocale = setlocale(LC_NUMERIC, "C");		FindTrackSeg(GPXRoot);	setlocale(LC_NUMERIC, OldLocale);	/* Clean up stuff for the XML library. */	xmlFreeDoc(GPXData);	xmlCleanupParser();	Track->Points = FirstPoint;	/* Find the time range for this track */	GetTrackRange(Track);	return 1;}
开发者ID:bruniii,项目名称:gpscorrelate,代码行数:85,


示例27: xmlSecSimpleKeysStoreLoad

/**  * xmlSecSimpleKeysStoreLoad: * @store:		the pointer to simple keys store. * @uri:		the filename. * @keysMngr:		the pointer to associated keys manager.  *  * Reads keys from an XML file. * * Returns 0 on success or a negative value if an error occurs. */intxmlSecSimpleKeysStoreLoad(xmlSecKeyStorePtr store, const char *uri, 			    xmlSecKeysMngrPtr keysMngr) {    xmlDocPtr doc;    xmlNodePtr root;    xmlNodePtr cur;    xmlSecKeyPtr key;    xmlSecKeyInfoCtx keyInfoCtx;    int ret;    xmlSecAssert2(xmlSecKeyStoreCheckId(store, xmlSecSimpleKeysStoreId), -1);    xmlSecAssert2(uri != NULL, -1);        doc = xmlParseFile(uri);    if(doc == NULL) {	xmlSecErr_a_ignorar6(XMLSEC_ERRORS_HERE,		    xmlSecErrorsSafeString(xmlSecKeyStoreGetName(store)),		    "xmlParseFile",		    XMLSEC_ERRORS_R_XML_FAILED,		    "uri=%s", 		    xmlSecErrorsSafeString(uri));	return(-1);    }        root = xmlDocGetRootElement(doc);    if(!xmlSecCheckNodeName(root, BAD_CAST "Keys", xmlSecNs)) {	xmlSecErr_a_ignorar5(XMLSEC_ERRORS_HERE,		    xmlSecErrorsSafeString(xmlSecKeyStoreGetName(store)),		    xmlSecErrorsSafeString(xmlSecNodeGetName(root)),		    XMLSEC_ERRORS_R_INVALID_NODE,		    "expected-node=<xmlsec:Keys>");	xmlFreeDoc(doc);	return(-1);    }            cur = xmlSecGetNextElementNode(root->children);    while((cur != NULL) && xmlSecCheckNodeName(cur, xmlSecNodeKeyInfo, xmlSecDSigNs)) {  	key = xmlSecKeyCreate();	if(key == NULL) {	    xmlSecErr_a_ignorar6(XMLSEC_ERRORS_HERE,			xmlSecErrorsSafeString(xmlSecKeyStoreGetName(store)),			xmlSecErrorsSafeString(xmlSecNodeGetName(cur)),			XMLSEC_ERRORS_R_INVALID_NODE,			"expected-node=%s",			xmlSecErrorsSafeString(xmlSecNodeKeyInfo));	    xmlFreeDoc(doc);	    return(-1);	}	ret = xmlSecKeyInfoCtxInitialize(&keyInfoCtx, NULL);	if(ret < 0) {	    xmlSecErr_a_ignorar5(XMLSEC_ERRORS_HERE,		        xmlSecErrorsSafeString(xmlSecKeyStoreGetName(store)),			"xmlSecKeyInfoCtxInitialize",			XMLSEC_ERRORS_R_XMLSEC_FAILED,			XMLSEC_ERRORS_NO_MESSAGE);	    xmlSecKeyDestroy(key);	    xmlFreeDoc(doc);	    return(-1);	}		keyInfoCtx.mode 	  = xmlSecKeyInfoModeRead;	keyInfoCtx.keysMngr	  = keysMngr;	keyInfoCtx.flags 	  = XMLSEC_KEYINFO_FLAGS_DONT_STOP_ON_KEY_FOUND |				    XMLSEC_KEYINFO_FLAGS_X509DATA_DONT_VERIFY_CERTS;        keyInfoCtx.keyReq.keyId	  = xmlSecKeyDataIdUnknown;	keyInfoCtx.keyReq.keyType = xmlSecKeyDataTypeAny;	keyInfoCtx.keyReq.keyUsage= xmlSecKeyDataUsageAny;	ret = xmlSecKeyInfoNodeRead(cur, key, &keyInfoCtx);	if(ret < 0) {	    xmlSecErr_a_ignorar5(XMLSEC_ERRORS_HERE,			xmlSecErrorsSafeString(xmlSecKeyStoreGetName(store)),			"xmlSecKeyInfoNodeRead",			XMLSEC_ERRORS_R_XMLSEC_FAILED,			XMLSEC_ERRORS_NO_MESSAGE);	    xmlSecKeyInfoCtxFinalize(&keyInfoCtx);	    xmlSecKeyDestroy(key);	    xmlFreeDoc(doc);	    return(-1);	}	xmlSecKeyInfoCtxFinalize(&keyInfoCtx);		if(xmlSecKeyIsValid(key)) {    	    ret = xmlSecSimpleKeysStoreAdoptKey(store, key);	    if(ret < 0) {		xmlSecErr_a_ignorar5(XMLSEC_ERRORS_HERE,			    xmlSecErrorsSafeString(xmlSecKeyStoreGetName(store)),			    "xmlSecSimpleKeysStoreAdoptKey",			    XMLSEC_ERRORS_R_XMLSEC_FAILED,//.........这里部分代码省略.........
开发者ID:Arcenciel,项目名称:DDReader,代码行数:101,


示例28: save_obconf_settings

static void save_obconf_settings (void){	const char *session_name;	char *user_config_file, *c, *font, *fname;	int count;	const gchar *size = NULL, *bold = NULL, *italic = NULL;	// construct the file path	session_name = g_getenv ("DESKTOP_SESSION");	if (!session_name) session_name = DEFAULT_SES;	fname = g_strconcat (g_ascii_strdown (session_name, -1), "-rc.xml", NULL);	user_config_file = g_build_filename (g_get_user_config_dir (), "openbox/", fname, NULL);	g_free (fname);	// set the font description variables for XML from the font name	font = g_strdup (desktop_font);	while ((c = strrchr (font, ' ')))	{		if (!bold && !italic && !size && atoi (c + 1))			size = c + 1;		else if (!bold && !italic && !g_ascii_strcasecmp (c + 1, "italic"))			italic = c + 1;		else if (!bold && !g_ascii_strcasecmp (c + 1, "bold"))			bold = c + 1;		else break;		*c = '/0';	}	if (!bold) bold = "Normal";	if (!italic) italic = "Normal";	// read in data from XML file	xmlInitParser ();	LIBXML_TEST_VERSION	xmlDocPtr xDoc = xmlParseFile (user_config_file);	if (xDoc == NULL)	{		g_free (font);		g_free (user_config_file);		return;	}	xmlXPathContextPtr xpathCtx = xmlXPathNewContext (xDoc);	xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression ((xmlChar *) "/*[local-name()='openbox_config']/*[local-name()='theme']/*[local-name()='font']", xpathCtx);	// update relevant nodes with new values	for (count = 0; count < xpathObj->nodesetval->nodeNr; count++)	{		xmlNode *node = xpathObj->nodesetval->nodeTab[count];		xmlAttr *attr = node->properties;		xmlNode *cur_node = NULL;		for (cur_node = node->children; cur_node; cur_node = cur_node->next)		{			if (cur_node->type == XML_ELEMENT_NODE)			{				if (!strcmp (cur_node->name, "name")) xmlNodeSetContent (cur_node, font);				if (!strcmp (cur_node->name, "size")) xmlNodeSetContent (cur_node, size);				if (!strcmp (cur_node->name, "weight")) xmlNodeSetContent (cur_node, bold);				if (!strcmp (cur_node->name, "slant"))	xmlNodeSetContent (cur_node, italic);			}		}	}	// cleanup XML	xmlXPathFreeObject (xpathObj);	xmlXPathFreeContext (xpathCtx);	xmlSaveFile (user_config_file, xDoc);	xmlFreeDoc (xDoc);	xmlCleanupParser ();	g_free (font);	g_free (user_config_file);}
开发者ID:l10n-tw,项目名称:pipanel,代码行数:72,


示例29: check_themes

static void check_themes (void){	const char *session_name, *ret;	char *user_config_file, *cptr, *nptr, *fname;	GKeyFile *kf;	GError *err;	int count;	orig_lxsession_theme = "";	orig_openbox_theme = "";	// construct the file path for lxsession settings	session_name = g_getenv ("DESKTOP_SESSION");	if (!session_name) session_name = DEFAULT_SES;	user_config_file = g_build_filename (g_get_user_config_dir (), "lxsession/", session_name, "/desktop.conf", NULL);	// read in data from file to a key file structure	kf = g_key_file_new ();	if (g_key_file_load_from_file (kf, user_config_file, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, NULL))	{		// get data from the key file		err = NULL;		ret = g_key_file_get_string (kf, "GTK", "sNet/ThemeName", &err);		if (err == NULL) orig_lxsession_theme = ret;	}	// construct the file path for openbox settings	fname = g_strconcat (g_ascii_strdown (session_name, -1), "-rc.xml", NULL);	user_config_file = g_build_filename (g_get_user_config_dir (), "openbox/", fname, NULL);	g_free (fname);	// read in data from XML file	xmlInitParser ();	LIBXML_TEST_VERSION	xmlDocPtr xDoc = xmlParseFile (user_config_file);	if (xDoc)	{		xmlXPathContextPtr xpathCtx = xmlXPathNewContext (xDoc);		xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression ((xmlChar *) "/*[local-name()='openbox_config']/*[local-name()='theme']", xpathCtx);		// find relevant node and read value		for (count = 0; count < xpathObj->nodesetval->nodeNr; count++)		{			xmlNode *node = xpathObj->nodesetval->nodeTab[count];			xmlAttr *attr = node->properties;			xmlNode *cur_node = NULL;			for (cur_node = node->children; cur_node; cur_node = cur_node->next)			{				if (cur_node->type == XML_ELEMENT_NODE)				{					if (!strcmp (cur_node->name, "name"))						orig_openbox_theme = xmlNodeGetContent (cur_node);				}			}		}		// cleanup XML		xmlXPathFreeObject (xpathObj);		xmlXPathFreeContext (xpathCtx);		xmlSaveFile (user_config_file, xDoc);		xmlFreeDoc (xDoc);		xmlCleanupParser ();	}	g_free (user_config_file);	// set the new themes if needed	if (strcmp ("PiX", orig_lxsession_theme))	{		set_lxsession_theme ("PiX");		if (needs_refresh) system (RELOAD_LXSESSION);	}	if (strcmp ("PiX", orig_openbox_theme))	{		set_openbox_theme ("PiX");		system (RELOAD_OPENBOX);	}}
开发者ID:l10n-tw,项目名称:pipanel,代码行数:78,


示例30: wrbuf_printf

//.........这里部分代码省略.........        }        for (attr = ptr->properties; attr; attr = attr->next)        {            if (!xmlStrcmp(attr->name, BAD_CAST "name") &&                attr->children && attr->children->type == XML_TEXT_NODE)                name = (const char *) attr->children->content;            else if (!xmlStrcmp(attr->name, BAD_CAST "value") &&                attr->children && attr->children->type == XML_TEXT_NODE)                value = (const char *) attr->children->content;            else            {                wrbuf_printf(wr_error, "Bad attribute '%s'"                             "Expected name or value.", attr->name);                nmem_destroy(nmem);                return 0;            }        }        if (!name || !value)        {            wrbuf_printf(wr_error, "Missing attributes name or value");            nmem_destroy(nmem);            return 0;        }        if (no_parms >= max_parms)        {            wrbuf_printf(wr_error, "Too many parameters given");            nmem_destroy(nmem);            return 0;        }        qvalue = nmem_malloc(nmem, strlen(value) + 3);        strcpy(qvalue, "/'");        strcat(qvalue, value);        strcat(qvalue, "/'");        info->xsl_parms[2 * no_parms] = nmem_strdup(nmem, name);        info->xsl_parms[2 * no_parms + 1] = qvalue;        no_parms++;    }    info->xsl_parms[2 * no_parms] = 0;    if (!stylesheet)    {        wrbuf_printf(wr_error, "Element <xslt>: "                     "attribute 'stylesheet' expected");        nmem_destroy(nmem);    }    else    {        char fullpath[1024];        xsltStylesheetPtr xsp;        if (!yaz_filepath_resolve(stylesheet, path, 0, fullpath))        {            wrbuf_printf(wr_error, "Element <xslt stylesheet=/"%s/"/>:"                         " could not locate stylesheet '%s'",                         stylesheet, stylesheet);            if (path)                wrbuf_printf(wr_error, " with path '%s'", path);            nmem_destroy(nmem);            return 0;        }        info->xsp_doc = xmlParseFile(fullpath);        if (!info->xsp_doc)        {            wrbuf_printf(wr_error, "Element: <xslt stylesheet=/"%s/"/>:"                         " xml parse failed: %s", stylesheet, fullpath);            if (path)                wrbuf_printf(wr_error, " with path '%s'", path);            nmem_destroy(nmem);            return 0;        }        /* need to copy this before passing it to the processor. It will           be encapsulated in the xsp and destroyed by xsltFreeStylesheet */        xsp = xsltParseStylesheetDoc(xmlCopyDoc(info->xsp_doc, 1));        if (!xsp)        {            wrbuf_printf(wr_error, "Element: <xslt stylesheet=/"%s/"/>:"                         " xslt parse failed: %s", stylesheet, fullpath);            if (path)                wrbuf_printf(wr_error, " with path '%s'", path);            wrbuf_printf(wr_error, " ("#if YAZ_HAVE_EXSLT                         "EXSLT enabled"#else                         "EXSLT not supported"#endif                         ")");            xmlFreeDoc(info->xsp_doc);            nmem_destroy(info->nmem);        }        else        {            xsltFreeStylesheet(xsp);            return info;        }    }    return 0;}
开发者ID:dcrossleyau,项目名称:yaz,代码行数:101,



注:本文中的xmlParseFile函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ xmlParseMemory函数代码示例
C++ xmlParseChunk函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。