这篇教程C++ xmlGetLastError函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xmlGetLastError函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlGetLastError函数的具体用法?C++ xmlGetLastError怎么用?C++ xmlGetLastError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xmlGetLastError函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: xml_throw_unlessvoidxml_throw_unless(bool condition) { if (!condition) { char const *message = "unknown XML error"; xmlErrorPtr xmlErr = xmlGetLastError(); if (xmlErr && xmlErr->message) { message = xmlErr->message; } error err("%s", message); xmlResetLastError(); throw err; }}
开发者ID:zasimov,项目名称:uatraits,代码行数:13,
示例2: rxml_xpath_expression_initialize/* call-seq: * XPath::Expression.new(expression) -> XPath::Expression * * Compiles an XPatch expression. This improves performance * when an XPath expression is called multiple times. * * doc = XML::Document.string('<header><first>hi</first></header>') * expr = XPath::Expression.new('//first') * nodes = doc.find(expr) */static VALUE rxml_xpath_expression_initialize(VALUE self, VALUE expression){ xmlXPathCompExprPtr compexpr = xmlXPathCompile((const xmlChar*)StringValueCStr(expression)); if (compexpr == NULL) { xmlErrorPtr xerror = xmlGetLastError(); rxml_raise(xerror); } DATA_PTR( self) = compexpr; return self;}
开发者ID:ericallam,项目名称:blather,代码行数:23,
示例3: parse_ticket_statestatic int parse_ticket_state(struct ticket_config *tk, FILE *p){ int rv = 0; GString *input = NULL; char line[CHUNK_SIZE]; xmlDocPtr doc = NULL; xmlErrorPtr errptr; int opts = XML_PARSE_COMPACT | XML_PARSE_NONET; /* skip first two lines of output */ if (fgets(line, CHUNK_SIZE-1, p) == NULL || fgets(line, CHUNK_SIZE-1, p) == NULL) { tk_log_error("crm_ticket xml output empty"); rv = ENODATA; goto out; } input = g_string_sized_new(CHUNK_SIZE); if (!input) { log_error("out of memory"); rv = -1; goto out; } while (fgets(line, CHUNK_SIZE-1, p) != NULL) { if (!g_string_append(input, line)) { log_error("out of memory"); rv = -1; goto out; } } doc = xmlReadDoc((const xmlChar *) input->str, NULL, NULL, opts); if (doc == NULL) { errptr = xmlGetLastError(); if (errptr) { tk_log_error("crm_ticket xml parse failed (domain=%d, level=%d, code=%d): %s", errptr->domain, errptr->level, errptr->code, errptr->message); } else { tk_log_error("crm_ticket xml parse failed"); } rv = -EINVAL; goto out; } rv = save_attributes(tk, doc);out: if (doc) xmlFreeDoc(doc); if (input) g_string_free(input, TRUE); return rv;}
开发者ID:ClusterLabs,项目名称:booth,代码行数:51,
示例4: xmlGetLastErrorconst int BEXMLReaderInterface::last_error ( const int default_error ){ xmlErrorPtr xml_error = xmlGetLastError(); // don't crash if there's no xml_error int error; if ( xml_error ) { error = xml_error->code; } else { error = default_error; } return error;}
开发者ID:chivalry,项目名称:BaseElements-Plugin,代码行数:14,
示例5: oscap_xml_save_filenameint oscap_xml_save_filename(const char *filename, xmlDocPtr doc){ xmlOutputBufferPtr buff; int xmlCode; if (strcmp(filename, "-") == 0) { xmlCode = xmlSaveFormatFileEnc(filename, doc, "UTF-8", 1); } else { int fd = open(filename, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); if (fd < 0) { oscap_seterr(OSCAP_EFAMILY_GLIBC, "%s '%s'", strerror(errno), filename); xmlFreeDoc(doc); return -1; } buff = xmlOutputBufferCreateFd(fd, NULL); if (buff == NULL) { close(fd); oscap_setxmlerr(xmlGetLastError()); oscap_dlprintf(DBG_W, "xmlOutputBufferCreateFile() failed./n"); xmlFreeDoc(doc); return -1; } xmlCode = xmlSaveFormatFileTo(buff, doc, "UTF-8", 1); close(fd); } if (xmlCode <= 0) { oscap_setxmlerr(xmlGetLastError()); oscap_dlprintf(DBG_W, "No bytes exported: xmlCode: %d./n", xmlCode); } return (xmlCode >= 1) ? 1 : -1;}
开发者ID:galaris,项目名称:openscap,代码行数:36,
示例6: wi_error_set_libxml2_errorvoid wi_error_set_libxml2_error(void) { wi_error_t *error; xmlErrorPtr xml_error; xml_error = xmlGetLastError(); error = _wi_get_error(); error->domain = WI_ERROR_DOMAIN_REGEX; error->code = xml_error->code; wi_release(error->string); error->string = wi_string_init_with_cstring(wi_string_alloc(), xml_error->message); wi_string_delete_surrounding_whitespace(error->string);}
开发者ID:ProfDrLuigi,项目名称:zanka,代码行数:15,
示例7: xccdf_detect_version_parserconst struct xccdf_version_info* xccdf_detect_version_parser(xmlTextReaderPtr reader){ const struct xccdf_version_info *mapptr; const char* namespace_uri = (const char*)xmlTextReaderConstNamespaceUri(reader); if (!namespace_uri) { oscap_setxmlerr(xmlGetLastError()); return NULL; } mapptr = _namespace_get_xccdf_version_info(namespace_uri); if (mapptr == NULL) oscap_seterr(OSCAP_EFAMILY_XML, "This is not known XCCDF namespace: %s.", namespace_uri); return mapptr;}
开发者ID:GovReady,项目名称:openscap,代码行数:15,
示例8: diaXmlParseFile/*! * /brief Parse an xml file from a filename given in Dia's/GLib's filename encoding * * @param filename A file to parse. On win32 the filename encoding is utf-8 since GLib 2.6 * @param ctx If something goes wrong during parsing ctx will include according messages * @param try_harder If set an additional attempt is done with guessed encoding * @return An XML document. * * /ingroup DiagramXmlIo */xmlDocPtr diaXmlParseFile(const char *filename, DiaContext *ctx, gboolean try_harder){ xmlDocPtr doc; xmlErrorPtr err; doc = xmlParseFile(filename); if (!doc) { err = xmlGetLastError (); dia_context_add_message (ctx, "%s", err->message); if (err->code == XML_ERR_INVALID_CHAR && try_harder) /* fallback to temporary file with encoding approach */ doc = xmlDiaParseFile (filename, ctx); } return doc;}
开发者ID:UIKit0,项目名称:dia,代码行数:26,
示例9: oval_definition_model_exportint oval_definition_model_export(struct oval_definition_model *model, const char *file){ __attribute__nonnull__(model); LIBXML_TEST_VERSION; xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0"); if (doc == NULL) { oscap_setxmlerr(xmlGetLastError()); return -1; } oval_definition_model_to_dom(model, doc, NULL); return oscap_xml_save_filename_free(file, doc);}
开发者ID:galaris,项目名称:openscap,代码行数:16,
示例10: wi_error_set_libxml2_errorvoid wi_error_set_libxml2_error(void) { wi_error_t *error; wi_string_t *string; xmlErrorPtr xml_error; xml_error = xmlGetLastError(); error = _wi_error_get_error(); error->domain = WI_ERROR_DOMAIN_REGEX; error->code = xml_error->code; string = wi_string_by_deleting_surrounding_whitespace(wi_string_with_cstring(xml_error->message)); wi_release(error->string); error->string = wi_retain(string);}
开发者ID:asvitkine,项目名称:phxd,代码行数:16,
示例11: xccdf_benchmark_exportint xccdf_benchmark_export(struct xccdf_benchmark *benchmark, const char *file){ __attribute__nonnull__(file); LIBXML_TEST_VERSION; xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0"); if (doc == NULL) { oscap_setxmlerr(xmlGetLastError()); return -1; } xccdf_benchmark_to_dom(benchmark, doc, NULL, NULL); return oscap_xml_save_filename(file, doc);}
开发者ID:GovReady,项目名称:openscap,代码行数:16,
示例12: parse_alps_outputint parse_alps_output( std::string &alps_output) { xmlDocPtr doc; xmlNode *child; if ((doc = xmlReadMemory(alps_output.c_str(), alps_output.length(), "apbasil", NULL, 0)) == NULL) { char buf[MAXLINE * 4]; xmlErrorPtr pErr = xmlGetLastError(); snprintf(buf, sizeof(buf), "Failed to parse the output of alps - %s", pErr->message); log_err(-1, __func__, buf); return(ALPS_PARSING_ERROR); } if (process_element(xmlDocGetRootElement(doc)) == ALPS_QUERY_FAILURE) { xmlNode *root = xmlDocGetRootElement(doc); // Verbose debug output for ALPS_QUERY_FAILURE node error message for (child = root->children; child != NULL; child = child->next) { if (!strcmp((const char *)child->name, response_data)) { for (xmlNode *gchild = child->children; gchild != NULL; gchild = gchild->next) { if (!strcmp((const char *)gchild->name, "Message")) { snprintf(log_buffer, sizeof(log_buffer), "Failed to query ALPS: %s", (const char *)xmlNodeGetContent(gchild)); log_record(PBSEVENT_SYSTEM, 0, __func__, log_buffer); } } } } return(ALPS_QUERY_FAILURE); } xmlFreeDoc(doc); xmlMemoryDump(); return(PBSE_NONE); } /* END parse_alps_output() */
开发者ID:msbritt,项目名称:torque,代码行数:46,
示例13: parse_confirmation_outputint parse_confirmation_output( char *output) { int rc = -1; xmlDocPtr doc; xmlNode *node; char *attr_val; if ((doc = xmlReadMemory(output, strlen(output), "apbasil", NULL, 0)) == NULL) { char buf[MAXLINE * 4]; xmlErrorPtr pErr = xmlGetLastError(); snprintf(buf, sizeof(buf), "Failed to parse the output of alps - %s", pErr->message); log_err(-1, __func__, buf); return(ALPS_PARSING_ERROR); } node = xmlDocGetRootElement(doc); while (node != NULL) { if (!strcmp((const char *)node->name, response_data)) { attr_val = (char *)xmlGetProp(node, (const xmlChar *)status); if (strcmp(attr_val, success)) { rc = find_error_type(node); } else rc = PBSE_NONE; free(attr_val); break; } else if (!strcmp((const char *)node->name, text_name)) node = node->next; else node = node->children; } return(rc); } /* END parse_confirmation_output() */
开发者ID:dhill12,项目名称:test,代码行数:46,
示例14: last_errorstatic ERL_NIF_TERM last_error(ErlNifEnv *env, char *fallback){ char *default_msg = (fallback) ? fallback : "Unknown"; /* This is thread safe as long as libxml2 has been compiled with * thread support (alternatively use a mutex) */ xmlErrorPtr err = xmlGetLastError(); /* Seems the useful error is in str1? */ char *err_str = (err && err->str1) ? err->str1 : (err && err->message) ? err->message : default_msg; return enif_make_tuple2(env, am_error(env), enif_make_string(env, err_str, ERL_NIF_LATIN1));}
开发者ID:tail-f-systems,项目名称:xsdre,代码行数:17,
示例15: _xml_error_handler/** libxml error handler */static void _xml_error_handler(void *ctx, const char *msg, ...){ xmlError *err; if(!(err = xmlGetLastError())) { NFT_LOG(L_WARNING, "libxml2 error trigger but no xmlGetLastError()"); return; } /* convert libxml error-level to loglevel */ NftLoglevel level = L_NOISY; switch (err->level) { case XML_ERR_NONE: { level = L_DEBUG; break; } case XML_ERR_WARNING: { level = L_WARNING; break; } case XML_ERR_ERROR: { level = L_ERROR; break; } case XML_ERR_FATAL: { level = L_ERROR; break; } }; va_list args; va_start(args, msg); nft_log_va(level, err->file, "libxml2", err->line, msg, args); va_end(args);}
开发者ID:niftylight,项目名称:niftyprefs,代码行数:47,
示例16: from_document/* * call-seq: * from_document(doc) * * Create a new RelaxNG schema from the Nokogiri::XML::Document +doc+ */static VALUE from_document(VALUE klass, VALUE document){ xmlDocPtr doc; xmlRelaxNGParserCtxtPtr ctx; xmlRelaxNGPtr schema; VALUE errors; VALUE rb_schema; Data_Get_Struct(document, xmlDoc, doc); /* In case someone passes us a node. ugh. */ doc = doc->doc; ctx = xmlRelaxNGNewDocParserCtxt(doc); errors = rb_ary_new(); Nokogiri_install_error_catcher(errors);#ifdef HAVE_XMLRELAXNGSETPARSERSTRUCTUREDERRORS xmlRelaxNGSetParserStructuredErrors( ctx, Nokogiri_error_array_pusher, (void *)errors );#endif schema = xmlRelaxNGParse(ctx); Nokogiri_remove_error_catcher(); if(NULL == schema) { xmlErrorPtr error = xmlGetLastError(); if(error) Nokogiri_error_raise(NULL, error); else rb_raise(rb_eRuntimeError, "Could not parse document"); return Qnil; } rb_schema = Data_Wrap_Struct(klass, 0, dealloc, schema); rb_iv_set(rb_schema, "@errors", errors); return rb_schema;}
开发者ID:tomhughes,项目名称:nokogiri,代码行数:51,
示例17: validateXmlStringvoid validateXmlString(const string& xml_string) { xmlDocPtr document_ptr = xmlParseMemory(xml_string.c_str(), xml_string.size()); if(document_ptr == 0) { xmlErrorPtr error_ptr = xmlGetLastError(); if(error_ptr) { stringstream formatter; formatter << "malformed xml: " << error_ptr->message << " at line " << error_ptr->line; xmlFreeDoc(document_ptr); throw runtime_error(formatter.str()); } } xmlFreeDoc(document_ptr);}
开发者ID:coinhelper,项目名称:coin,代码行数:18,
示例18: from_document/* * call-seq: * from_document(doc) * * Create a new Schema from the Nokogiri::XML::Document +doc+ */static VALUE from_document(VALUE klass, VALUE document){ xmlDocPtr doc; Data_Get_Struct(document, xmlDoc, doc); // In case someone passes us a node. ugh. doc = doc->doc; xmlSchemaParserCtxtPtr ctx = xmlSchemaNewDocParserCtxt(doc); VALUE errors = rb_ary_new(); xmlSetStructuredErrorFunc((void *)errors, Nokogiri_error_array_pusher);#ifdef HAVE_XMLSCHEMASETPARSERSTRUCTUREDERRORS xmlSchemaSetParserStructuredErrors( ctx, Nokogiri_error_array_pusher, (void *)errors );#endif xmlSchemaPtr schema = xmlSchemaParse(ctx); xmlSetStructuredErrorFunc(NULL, NULL); xmlSchemaFreeParserCtxt(ctx); if(NULL == schema) { xmlErrorPtr error = xmlGetLastError(); if(error) Nokogiri_error_raise(NULL, error); else rb_raise(rb_eRuntimeError, "Could not parse document"); return Qnil; } VALUE rb_schema = Data_Wrap_Struct(klass, 0, dealloc, schema); rb_iv_set(rb_schema, "@errors", errors); return rb_schema; return Qnil;}
开发者ID:AndreasKrueger,项目名称:nokogiri,代码行数:49,
示例19: read_io/* * call-seq: * read_io(io, url, encoding, options) * * Create a new document from an IO object */static VALUE read_io( VALUE klass, VALUE io, VALUE url, VALUE encoding, VALUE options ){ const char * c_url = NIL_P(url) ? NULL : StringValuePtr(url); const char * c_enc = NIL_P(encoding) ? NULL : StringValuePtr(encoding); VALUE error_list = rb_ary_new(); VALUE document; xmlDocPtr doc; xmlResetLastError(); Nokogiri_install_error_catcher(error_list); doc = xmlReadIO( (xmlInputReadCallback)io_read_callback, (xmlInputCloseCallback)io_close_callback, (void *)io, c_url, c_enc, (int)NUM2INT(options) ); Nokogiri_remove_error_catcher(); if(doc == NULL) { xmlErrorPtr error; xmlFreeDoc(doc); error = xmlGetLastError(); if(error) rb_exc_raise(Nokogiri_wrap_xml_syntax_error((VALUE)NULL, error)); else rb_raise(rb_eRuntimeError, "Could not parse document"); return Qnil; } document = Nokogiri_wrap_xml_document(klass, doc); rb_iv_set(document, "@errors", error_list); return document;}
开发者ID:tomhughes,项目名称:nokogiri,代码行数:49,
示例20: read_io/* * call-seq: * read_io(io, url, encoding, options) * * Create a new document from an IO object */static VALUE read_io( VALUE klass, VALUE io, VALUE url, VALUE encoding, VALUE options ){ const char * c_url = (url == Qnil) ? NULL : StringValuePtr(url); const char * c_enc = (encoding == Qnil) ? NULL : StringValuePtr(encoding); VALUE error_list = rb_ary_new(); xmlInitParser(); xmlResetLastError(); xmlSetStructuredErrorFunc((void *)error_list, Nokogiri_error_array_pusher); xmlDocPtr doc = xmlReadIO( (xmlInputReadCallback)io_read_callback, (xmlInputCloseCallback)io_close_callback, (void *)io, c_url, c_enc, NUM2INT(options) ); xmlSetStructuredErrorFunc(NULL, NULL); if(doc == NULL) { xmlFreeDoc(doc); xmlErrorPtr error = xmlGetLastError(); if(error) rb_funcall(rb_mKernel, rb_intern("raise"), 1, Nokogiri_wrap_xml_syntax_error((VALUE)NULL, error) ); else rb_raise(rb_eRuntimeError, "Could not parse document"); return Qnil; } VALUE document = Nokogiri_wrap_xml_document(klass, doc); rb_funcall(document, rb_intern("errors="), 1, error_list); return document;}
开发者ID:halorgium,项目名称:nokogiri,代码行数:48,
示例21: parse_xml_to_cachestatic int parse_xml_to_cache(const char *xml, int xlen, const char *cachepath, const char *cachefile){ int retc = -1; xmlDoc *doc = NULL; xmlNode *root = NULL; /* suggested ABI check */ LIBXML_TEST_VERSION doc = xmlReadMemory(xml, xlen, "xml", NULL, 0); if (doc == NULL) { xmlError *pErr = xmlGetLastError(); if (pErr == NULL) { printf("panic!/n"); exit(100); } printf("Error parsing #%d (%d,%d)/n", pErr->code, pErr->line,pErr->int2); goto cleanup; } root = xmlDocGetRootElement(doc); if (strcmp((char *) root->name, "GANGLIA_XML") != 0) { goto cleanup; } if (parse_xml_tree_to_cache(root, cachepath, cachefile) != 0) retc = 0;cleanup: xmlFreeDoc(doc); xmlCleanupParser(); return retc;}
开发者ID:RPI-HPC,项目名称:check_ganglia_metric,代码行数:42,
示例22: xmlDocGetRootElementint Document::ProcessXInclude(bool generateXIncludeNodes){ NodeMap nmap; xmlNodePtr root = xmlDocGetRootElement(xml()); find_wrappers(root, nmap); xmlResetLastError(); int substitutionCount = xmlXIncludeProcessTreeFlags(root, generateXIncludeNodes ? 0 : XML_PARSE_NOXINCNODE); prune_unchanged_wrappers(Node::xml(), nmap); for ( auto item : nmap ) { delete item.first; } if ( substitutionCount < 0 ) throw InternalError("Failed to process XInclude", xmlGetLastError()); return substitutionCount;}
开发者ID:phamquy,项目名称:readium-sdk,代码行数:20,
示例23: xmlGetLastErrorstatic GError *gvir_config_error_new_literal(GQuark domain, gint code, const gchar *message){ xmlErrorPtr xerr = xmlGetLastError(); if (!xerr) return NULL; if (message) return g_error_new(domain, code, "%s: %s", message, xerr->message); else return g_error_new(domain, code, "%s", xerr->message);}
开发者ID:libvirt,项目名称:libvirt-glib,代码行数:21,
示例24: read_memory/* * call-seq: * read_memory(string) * * Create a new RelaxNG from the contents of +string+ */static VALUE read_memory(VALUE klass, VALUE content){ xmlRelaxNGParserCtxtPtr ctx = xmlRelaxNGNewMemParserCtxt( (const char *)StringValuePtr(content), (int)RSTRING_LEN(content) ); xmlRelaxNGPtr schema; VALUE errors = rb_ary_new(); VALUE rb_schema; Nokogiri_install_error_catcher(errors);#ifdef HAVE_XMLRELAXNGSETPARSERSTRUCTUREDERRORS xmlRelaxNGSetParserStructuredErrors( ctx, Nokogiri_error_array_pusher, (void *)errors );#endif schema = xmlRelaxNGParse(ctx); Nokogiri_remove_error_catcher(); xmlRelaxNGFreeParserCtxt(ctx); if(NULL == schema) { xmlErrorPtr error = xmlGetLastError(); if(error) Nokogiri_error_raise(NULL, error); else rb_raise(rb_eRuntimeError, "Could not parse document"); return Qnil; } rb_schema = Data_Wrap_Struct(klass, 0, dealloc, schema); rb_iv_set(rb_schema, "@errors", errors); return rb_schema;}
开发者ID:tomhughes,项目名称:nokogiri,代码行数:46,
示例25: read_memory/* * call-seq: * read_memory(string) * * Create a new Schema from the contents of +string+ */static VALUE read_memory(VALUE klass, VALUE content){ xmlSchemaParserCtxtPtr ctx = xmlSchemaNewMemParserCtxt( (const char *)StringValuePtr(content), RSTRING_LEN(content) ); VALUE errors = rb_ary_new(); xmlSetStructuredErrorFunc((void *)errors, Nokogiri_error_array_pusher); xmlSchemaSetParserStructuredErrors( ctx, Nokogiri_error_array_pusher, (void *)errors ); xmlSchemaPtr schema = xmlSchemaParse(ctx); xmlSetStructuredErrorFunc(NULL, NULL); xmlSchemaFreeParserCtxt(ctx); if(NULL == schema) { xmlErrorPtr error = xmlGetLastError(); if(error) rb_funcall(rb_mKernel, rb_intern("raise"), 1, Nokogiri_wrap_xml_syntax_error((VALUE)NULL, error) ); else rb_raise(rb_eRuntimeError, "Could not parse document"); return Qnil; } VALUE rb_schema = Data_Wrap_Struct(klass, 0, dealloc, schema); rb_iv_set(rb_schema, "@errors", errors); return rb_schema;}
开发者ID:fblee,项目名称:nokogiri,代码行数:45,
示例26: _model_info_merge_file/*! /brief Attempts to merge model information from a data file. */static SANE_Status_model_info_merge_file (_model_info_t *self){ xmlDocPtr doc = NULL; char *path_name = NULL; char *hex_name = NULL; require (self); hex_name = fw_name_to_hex (self->fw_name); if (!hex_name) return SANE_STATUS_NO_MEM; path_name = get_path_name (hex_name, NULL, 0); delete (hex_name); /* no longer needed */ if (!path_name) return SANE_STATUS_NO_MEM; log_data ("%s", path_name); doc = xmlReadFile (path_name, NULL, XML_PARSE_NOERROR | XML_PARSE_NOWARNING); delete (path_name); /* no longer needed */ if (doc) { _model_info_merge_data (self, xmlDocGetRootElement (doc)); xmlFreeDoc (doc); } else { xmlErrorPtr p = xmlGetLastError (); if (p) err_minor ("%s", p->message); } return SANE_STATUS_GOOD;}
开发者ID:hean01,项目名称:iscan,代码行数:40,
示例27: rxml_xpath_to_valueVALUErxml_xpath_to_value(xmlXPathContextPtr xctxt, xmlXPathObjectPtr xobject) { VALUE result; int type; if (xobject == NULL) { /* xmlLastError is different than xctxt->lastError. Use xmlLastError since it has the message set while xctxt->lastError does not. */ xmlErrorPtr xerror = xmlGetLastError(); rxml_raise(xerror); } switch (type = xobject->type) { case XPATH_NODESET: result = rxml_xpath_object_wrap(xctxt->doc, xobject); break; case XPATH_BOOLEAN: result = (xobject->boolval != 0) ? Qtrue : Qfalse; xmlXPathFreeObject(xobject); break; case XPATH_NUMBER: result = rb_float_new(xobject->floatval); xmlXPathFreeObject(xobject); break; case XPATH_STRING: result = rxml_new_cstr(xobject->stringval, xctxt->doc->encoding); xmlXPathFreeObject(xobject); break; default: xmlXPathFreeObject(xobject); rb_raise(rb_eTypeError, "can't convert XPath object of type %d to Ruby value", type ); } return result;}
开发者ID:boutil,项目名称:libxml-ruby,代码行数:38,
示例28: geonames_request_cbstatic void geonames_request_cb(net_result_t *result, gpointer data) { GError *err; request_cb_t *context = (request_cb_t*)data; g_message("asynchronous request callback."); g_return_if_fail(context && context->cb); if(!result->code) { /* feed this into the xml parser */ xmlDoc *doc = NULL; LIBXML_TEST_VERSION; g_message("Got: %s", result->data.ptr); g_message("analysing..."); /* parse the file and get the DOM */ if((doc = xmlReadMemory(result->data.ptr, result->data.len, NULL, NULL, 0)) == NULL) { xmlErrorPtr errP = xmlGetLastError(); err = g_error_new(MAEP_NET_IO_ERROR, 0, "While parsing:/n%s", errP->message); context->cb(context->obj, NULL, err); g_error_free(err); } else { g_message("XML parsed without error"); GSList *list = geonames_parse_doc(doc); context->cb(context->obj, list, (GError*)0); } } else { err = g_error_new(MAEP_NET_IO_ERROR, 0, "Geonames download failed!"); context->cb(context->obj, NULL, err); g_error_free(err); } g_free(context);}
开发者ID:FlavioFalcao,项目名称:maep-qt,代码行数:38,
示例29: rxml_xpath_context_find/* * call-seq: * context.find("xpath") -> XML::XPath::Object * * Find nodes matching the specified XPath expression */static VALUE rxml_xpath_context_find(VALUE self, VALUE xpath_expr){ xmlXPathContextPtr xctxt; xmlXPathObjectPtr xobject; xmlXPathCompExprPtr xcompexpr; VALUE result; Data_Get_Struct(self, xmlXPathContext, xctxt); if (TYPE(xpath_expr) == T_STRING) { VALUE expression = rb_check_string_type(xpath_expr); xobject = xmlXPathEval((xmlChar*) StringValueCStr(expression), xctxt); } else if (rb_obj_is_kind_of(xpath_expr, cXMLXPathExpression)) { Data_Get_Struct(xpath_expr, xmlXPathCompExpr, xcompexpr); xobject = xmlXPathCompiledEval(xcompexpr, xctxt); } else { rb_raise(rb_eTypeError, "Argument should be an intance of a String or XPath::Expression"); } if (xobject == NULL) { /* xmlLastError is different than xctxt->lastError. Use xmlLastError since it has the message set while xctxt->lastError does not. */ xmlErrorPtr xerror = xmlGetLastError(); rxml_raise(xerror); } result = rxml_xpath_object_wrap(xobject); rb_iv_set(result, "@context", self); return result;}
开发者ID:ericallam,项目名称:blather,代码行数:44,
注:本文中的xmlGetLastError函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ xmlGetProp函数代码示例 C++ xmlGetGlobalState函数代码示例 |