当前位置: 首页>>代码示例>>C++>>正文


C++ xmlReadMemory函数代码示例

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


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

示例1: wi_plist_instance_for_string

wi_runtime_instance_t * wi_plist_instance_for_string(wi_string_t *string) {
	wi_runtime_instance_t	*instance;
	xmlDocPtr				doc;
	
	doc = xmlReadMemory(wi_string_cstring(string), wi_string_length(string), NULL, NULL, 0);
	
	if(!doc) {
		wi_error_set_libxml2_error();
		
		return NULL;
	}
	
	instance = _wi_plist_instance_for_document(doc);
	
	xmlFreeDoc(doc);
	
	return instance;
}
开发者ID:Patater,项目名称:libwired,代码行数:18,代码来源:wi-plist.c

示例2: xml_create_context_mem

struct iio_context * xml_create_context_mem(const char *xml, size_t len)
{
    struct iio_context *ctx;
    xmlDoc *doc;

    LIBXML_TEST_VERSION;

    doc = xmlReadMemory(xml, (int) len, NULL, NULL, XML_PARSE_DTDVALID);
    if (!doc) {
        ERROR("Unable to parse XML file\n");
        return NULL;
    }

    ctx = iio_create_xml_context_helper(doc);
    xmlFreeDoc(doc);
    xmlCleanupParser();
    return ctx;
}
开发者ID:steev,项目名称:libiio,代码行数:18,代码来源:xml.c

示例3: xmlReadMemory

feed parser::parse_buffer(const char * buffer, size_t size, const char * url) {
	doc = xmlReadMemory(buffer, size, url, NULL, XML_PARSE_RECOVER | XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
	if (doc == NULL) {
		throw exception(_("could not parse buffer"));
	}

	xmlNode* root_element = xmlDocGetRootElement(doc);

	feed f = parse_xmlnode(root_element);

	if (doc->encoding) {
		f.encoding = (const char *)doc->encoding;
	}

	LOG(LOG_INFO, "parser::parse_buffer: encoding = %s", f.encoding.c_str());

	return f;
}
开发者ID:dsoul,项目名称:newsbeuter,代码行数:18,代码来源:parser.cpp

示例4: uSize

 cocos2d::CCDictionary *dictionaryFromPlist(const char *pFileName){
     xmlDoc *doc(0);
     xmlNode *root_element(0);
     
     /*
      * this initialize the library and check potential ABI mismatches
      * between the version it was compiled for and the actual shared
      * library used.
      */
     LIBXML_TEST_VERSION
     
     /*parse the file and get the DOM */
     
     // on android i seem to have to go through ccfileutils to get the data, may as well always do it
     
     
     
     unsigned long  uSize(0);
     xmlChar * xmlBuff(cocos2d::CCFileUtils::sharedFileUtils()->getFileData(pFileName, "r", &uSize));
     if (uSize)
         doc = xmlReadMemory((const char *)xmlBuff, uSize, "", 0, XML_PARSE_NOBLANKS);
     
     CC_SAFE_DELETE_ARRAY(xmlBuff);
     
     //could not parse the file pFileName!
     assert(doc);
     
     /*Get the root element node */
     root_element = xmlDocGetRootElement(doc);
     //  print_element_names(root_element, "");
     cocos2d::CCDictionary *d = (cocos2d::CCDictionary *) allocValueForNode(root_element->children);
     d->autorelease();
     
     /*free the document */
     xmlFreeDoc(doc);
     /*
      *Free the global variables that may
      *have been allocated by the parser.
      */
     xmlCleanupParser();
     
     return d;
 }
开发者ID:x007th,项目名称:mcbPlatformSupport,代码行数:43,代码来源:mcbPlatformSupport.cpp

示例5: rtS3ReadXmlFromMemory

static int rtS3ReadXmlFromMemory(PRTS3TMPMEMCHUNK pChunk, const char* pszRootElement, xmlDocPtr *ppDoc, xmlNodePtr *ppCur)
{
    *ppDoc = xmlReadMemory(pChunk->pszMem, (int)pChunk->cSize, "", "ISO-8859-1", XML_PARSE_NOBLANKS | XML_PARSE_NONET);
    if (*ppDoc == NULL)
        return VERR_PARSE_ERROR;

    *ppCur = xmlDocGetRootElement(*ppDoc);
    if (*ppCur == NULL)
    {
        xmlFreeDoc(*ppDoc);
        return VERR_PARSE_ERROR;
    }
    if (xmlStrcmp((*ppCur)->name, (const xmlChar *) pszRootElement))
    {
        xmlFreeDoc(*ppDoc);
        return VERR_PARSE_ERROR;
    }
    return VINF_SUCCESS;
}
开发者ID:mcenirm,项目名称:vbox,代码行数:19,代码来源:s3.cpp

示例6: xmlReadMemory

char *filter(char *str, Regexfilter *filterList) 
{
	
	xmlDocPtr doc;
	xmlNodePtr item_node, title_node;
	xmlChar *xmlbuff, *title_content;
	int buffersize;
	
	doc = xmlReadMemory(str, strlen(str), "noname.xml", NULL, 0);
	
	if (doc == NULL) {
		fprintf(stderr, "Failed to parse document\n");
		return;
	}
	
	item_node = feed_first_item(doc);
	
	/* loop through items */
	while (item_node != NULL) {
		
		title_node = xmlFirstElementChild(item_node); 
		title_content = xmlNodeGetContent(title_node);

		if (!pattern_check((char *)title_content, filterList)) {
			/* remove <item> node and leftover space*/
			feed_remove_node(&item_node);
			feed_remove_node(&item_node);
		}
		
		item_node = xmlNextElementSibling(item_node);
	}

	
	/* 
	 * Convert rss doc to string 
	 * and return.
	 */
	xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize,1);
	
	xmlFreeDoc(doc);
	
	return xmlbuff;
}
开发者ID:fiktivkod,项目名称:rssfilter,代码行数:43,代码来源:rssfilter.c

示例7: check_configuration

/**
    Provides to parse a configuration file
*/
static void check_configuration ()
{
    int fsize;
    gchar *file;
    xmlDocPtr doc;

    file = read_configuration (&fsize);
    doc = xmlReadMemory (file, fsize, NULL, NULL, XML_PARSE_NOBLANKS);

    if (doc == NULL) {
        g_warning ("Unable to read configuration");
    }
    else {
        build_hierarchy_tree_from_xml (doc);
        xmlFreeDoc (doc);
    }

    g_free (file);
}
开发者ID:netvandal,项目名称:FSter,代码行数:22,代码来源:fuse.c

示例8: reset

//
// readString:
//
bool XMLTableParser::readString(const std::string &inString, xmlNode *node ){
	
	reset();
	
	// read document from string
	_document = xmlReadMemory(inString.c_str(), inString.size(), NULL, NULL, 0);
	
	if (_document == NULL)
	{
		throw Exception("XMLTableParser::readString()","Could not parse %s XML string",inString.c_str());
	}
	
	// get start node
	if(node) _rootElement = node;
	else _rootElement = xmlDocGetRootElement(_document);
	
	return _readDocument();
	
}
开发者ID:daleathan,项目名称:Madeline_2.0_PDE,代码行数:22,代码来源:XMLTableParser.cpp

示例9: parse_xml_to_cache

static 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,代码来源:check_ganglia_metric.c

示例10: osync_trace

OSyncXMLFormat *osync_xmlformat_parse(const char *buffer, unsigned int size, OSyncError **error)
{
  OSyncXMLFormat *xmlformat = NULL;
  xmlNodePtr cur = NULL;
  osync_trace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, buffer, size, error);
  osync_assert(buffer);

  xmlformat = osync_try_malloc0(sizeof(OSyncXMLFormat), error);
  if(!xmlformat) {
    osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error));
    return NULL;
  }
	
  xmlformat->doc = xmlReadMemory(buffer, size, NULL, NULL, XML_PARSE_NOBLANKS);
  if(!xmlformat->doc) {
    g_free(xmlformat);
    osync_error_set(error, OSYNC_ERROR_GENERIC, "Could not parse XML.");
    osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error));
    return NULL;	
  }

  xmlformat->ref_count = 1;
  xmlformat->first_child = NULL;
  xmlformat->last_child = NULL;
  xmlformat->child_count = 0;
  xmlformat->doc->_private = xmlformat;
		
  cur = xmlDocGetRootElement(xmlformat->doc);
  cur = cur->children;
  while (cur != NULL) {
    OSyncXMLField *xmlfield = osync_xmlfield_new_node(xmlformat, cur, error);
    if(!xmlfield) {
      osync_xmlformat_unref(xmlformat);
      osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error));
      return NULL;
    }
    cur = cur->next;
  }

  osync_trace(TRACE_EXIT, "%s: %p", __func__, xmlformat);
  return xmlformat;
}
开发者ID:ianmartin,项目名称:autoimportopensync,代码行数:42,代码来源:opensync_xmlformat.c

示例11: xmlSetGenericErrorFunc

void cepgdata2xmltv::LoadXSLT()
{
    if (pxsltStylesheet) return;
    xmlSetGenericErrorFunc(NULL,tvmGenericErrorFunc);
    xmlSubstituteEntitiesDefault (1);
    xmlLoadExtDtdDefaultValue = 1;
    xmlSetExternalEntityLoader(xmlMyExternalEntityLoader);
    exsltRegisterAll();

    if ((sxmlDoc = xmlReadMemory (xsl, sizeof(xsl), NULL,NULL,0)) != NULL)
    {
        pxsltStylesheet=xsltParseStylesheetDoc(sxmlDoc);
        if (!pxsltStylesheet)
        {
            esyslog("can't parse stylesheet");
            xmlFreeDoc (sxmlDoc);
            sxmlDoc=NULL;
        }
    }
}
开发者ID:hertell,项目名称:vdr-plugin-xmltv2vdr,代码行数:20,代码来源:epgdata2xmltv.cpp

示例12: v2v_xml_parse_memory

value
v2v_xml_parse_memory (value xmlv)
{
  CAMLparam1 (xmlv);
  CAMLlocal1 (docv);
  xmlDocPtr doc;

  /* For security reasons, call xmlReadMemory (not xmlParseMemory) and
   * pass XML_PARSE_NONET.  See commit 845daded5fddc70f.
   */
  doc = xmlReadMemory (String_val (xmlv), caml_string_length (xmlv),
                       NULL, NULL, XML_PARSE_NONET);
  if (doc == NULL)
    caml_invalid_argument ("parse_memory: unable to parse XML from libvirt");

  docv = caml_alloc_custom (&doc_custom_operations, sizeof (xmlDocPtr), 0, 1);
  Doc_val (docv) = doc;

  CAMLreturn (docv);
}
开发者ID:kelledge,项目名称:libguestfs,代码行数:20,代码来源:xml-c.c

示例13: main

/**
 * Simple example to parse a file called "file.xml", 
 * walk down the DOM, and print the name of the 
 * xml elements nodes.
 */
int
main(int argc, char **argv)
{
    xmlDoc *doc = NULL;
    xmlNode *root_element = NULL;
/*
    if (argc != 2)
        return(1);
*/
    /*
     * this initialize the library and check potential ABI mismatches
     * between the version it was compiled for and the actual shared
     * library used.
     */
    LIBXML_TEST_VERSION

    /*parse the file and get the DOM */
    doc = xmlReadMemory("<request type=\"hello\"><item name=\"world\"/></request>", strlen("<request type=\"hello\"><item name=\"world\"/></request>"), "noname.xml", NULL, 0);

    if (doc == NULL) {
        printf("error: could not parse file %s\n", argv[1]);
    }

    /*Get the root element node */
    root_element = xmlDocGetRootElement(doc);
	
	printf("Root element type = %s\n", xmlGetProp(root_element, "type"));
	
    print_element_names(root_element);

    /*free the document */
    xmlFreeDoc(doc);

    /*
     *Free the global variables that may
     *have been allocated by the parser.
     */
    xmlCleanupParser();

    return 0;
}
开发者ID:davidmerrick,项目名称:Classes,代码行数:46,代码来源:parse_xml.c

示例14: empathy_plist_parse_from_memory

/**
 * empathy_plist_parse_from_memory:
 * @data:   memory location containing XML plist data to parse
 * @len:	length in bytes of the string to parse
 *
 * Parses the XML plist file stored in @data which length is @len
 * bytes. If an error occurs during the parsing,
 * empathy_plist_parse_from_memory() will return NULL.
 *
 * Returns: NULL on error, a newly allocated
 * #GValue otherwise. Free it using tp_g_value_slice_free()
 */
GValue *
empathy_plist_parse_from_memory (const char *data, gsize len)
{
	xmlDoc *doc = NULL;
	xmlNode *root_element = NULL;
	GValue *parsed_doc;

	doc = xmlReadMemory (data, len, "noname.xml", NULL, 0);

	if (doc == NULL) {
		return NULL;
	}

	root_element = xmlDocGetRootElement (doc);

	parsed_doc = empathy_plist_parse (root_element);

	xmlFreeDoc (doc);

	return parsed_doc;
}
开发者ID:Dhinihan,项目名称:empathy,代码行数:33,代码来源:empathy-plist.c

示例15: parse_xml_buffer

void parse_xml_buffer(const char *url, const char *buffer, int size,
			struct dive_table *table, GError **error)
{
	xmlDoc *doc;

	target_table = table;
	doc = xmlReadMemory(buffer, size, url, NULL, 0);
	if (!doc) {
		fprintf(stderr, _("Failed to parse '%s'.\n"), url);
		parser_error(error, _("Failed to parse '%s'"), url);
		return;
	}
	reset_all();
	dive_start();
#ifdef XSLT
	doc = test_xslt_transforms(doc, error);
#endif
	traverse(xmlDocGetRootElement(doc));
	dive_end();
	xmlFreeDoc(doc);
}
开发者ID:syuxue,项目名称:subsurface,代码行数:21,代码来源:parse-xml.c


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