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


C++ xmlNodeDump函数代码示例

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


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

示例1: list_to_xml1

char * list_to_xml1(list_t list) {
    xmlDoc * doc = NULL;
	xmlNode * rootNode = NULL;
	xmlNode * studentNode = NULL;
	xmlNode * groupNode = NULL;
	char strBuf[100];
	char * text = malloc(sizeof (char) * 10000);
	doc = xmlNewDoc("1.0");
	rootNode = xmlNewNode(NULL, "directors");

	for (int i = 0;i < list_size(list); i++)
	{
		if (list_get(list, i) == NULL)
			continue;
		puts(((struct admin_s *)list_get(list, i))->name);
		xmlDocSetRootElement(doc, rootNode);
		studentNode = xmlNewChild(rootNode, NULL, "director", NULL);
		xmlNewChild(studentNode, NULL, "name", ((struct admin_s *)list_get(list, i))->name);
		xmlNewChild(studentNode, NULL, "surname", ((struct admin_s *)list_get(list, i))->surname);
		sprintf(strBuf, "%i", ((struct admin_s *)list_get(list, i))->buget);
		xmlNewChild(studentNode, NULL, "buget", strBuf);
		sprintf(strBuf, "%llf", ((struct admin_s *)list_get(list, i))->years);
		xmlNewChild(studentNode, NULL, "years", strBuf);
		xmlNewChild(studentNode, NULL, "birthdate", ((struct admin_s *)list_get(list, i))->birthdate);
	}
	xmlBuffer * bufferPtr = xmlBufferCreate();
		xmlNodeDump(bufferPtr, NULL, (xmlNode *)doc, 0, 1);
		printf("%s", (const char *)bufferPtr->content);
    
		strcpy(text, (const char *)bufferPtr->content);
		xmlBufferFree(bufferPtr);
      xmlFreeDoc(doc);
	xmlCleanupParser();
	return text;
}
开发者ID:AlexandraPV,项目名称:Repository,代码行数:35,代码来源:xml.c

示例2: xmlNewDoc

char *teacher_to_message(teacher_t *self, int id){
    if(!self)
        return NULL;
    char buff[MSG_LENGTH];
    xmlDoc * doc = NULL;
	xmlNode * rootNode = NULL;
	xmlNode * teacherNode = NULL;
	xmlNode * cathedraNode = NULL;
    doc = xmlNewDoc("1.0");
	rootNode = xmlNewNode(NULL, "teachers");
	xmlDocSetRootElement(doc, rootNode);
	char strBuf[100];
	teacherNode = xmlNewChild(rootNode, NULL, "teacher", NULL);
	sprintf(strBuf, "%i", id);
	xmlNewChild(teacherNode, NULL, "id", strBuf);
	xmlNewChild(teacherNode, NULL, "firstName", self->name);
	xmlNewChild(teacherNode, NULL, "lastName", self->surname);
	xmlNewChild(teacherNode, NULL, "pensionDate", self->date);
	sprintf(strBuf, "%i", self->hours);
	xmlNewChild(teacherNode, NULL, "hours", strBuf);
	sprintf(strBuf, "%f", self->rating);
	xmlNewChild(teacherNode, NULL, "rating", strBuf);
	cathedraNode = xmlNewChild(teacherNode, NULL, "cathedra", NULL);
	xmlNewProp(cathedraNode, "name", self->cathedra->name);
	xmlNewChild(cathedraNode, NULL, "speciality", self->cathedra->speciality);
	xmlNewChild(cathedraNode, NULL, "group", self->cathedra->groups[0]);
	xmlNewChild(cathedraNode, NULL, "group", self->cathedra->groups[1]);
	xmlBuffer * bufferPtr = xmlBufferCreate();
	xmlNodeDump(bufferPtr, NULL, (xmlNode *)doc, 0, 1);
	sprintf(buff, "%s", (const char*)bufferPtr->content);
    xmlFreeDoc(doc);
	xmlCleanupParser();
	xmlBufferFree(bufferPtr);
    return buff;
}
开发者ID:GlebDavydov,项目名称:Davydov-KP-52,代码行数:35,代码来源:xmlprocess.c

示例3: fprintf

bool
Xml::saveToBuffer(XmlNode *curNode, std::string *buf) const
{
    if (NULL == curNode) {
        fprintf(stderr, "[ERROR] In Xml::saveToBuffer, curNode == NULL\n");
        return false;
    }

    if (NULL == buf) {
        fprintf(stderr, "[ERROR] In Xml::saveToBuffer, buf == NULL\n");
        return false;
    }

    xmlBuffer *xmlBuf = xmlBufferCreate();

    if (NULL == xmlBuf) {
        fprintf(stderr, "[ERROR] In Xml::saveToBuffer, "
                "xmlBufferCreate() error\n");
        return false;
    }

    int bytes = xmlNodeDump(xmlBuf, _doc, curNode,
                            XML_INDENT_LEVEL, XML_FORMAT_ALLOWED);

    if (bytes < 0) {
        fprintf(stderr, "[ERROR] In Xml::saveToBuffer, xmlNodeDump() error\n");
        return false;
    }

    *buf = (const char *)(xmlBuf->content);
    xmlBufferFree(xmlBuf);
    xmlBuf = NULL;

    return true;
}
开发者ID:sreadfox,项目名称:ossfs,代码行数:35,代码来源:Xml.cpp

示例4: xmlBufferCreate

void TrackerConfig::dump() const
{
    string s;
    xmlBufferPtr pBuffer = xmlBufferCreate();
    xmlNodeDump(pBuffer, m_Doc, m_pRoot, 0, 0);
    cerr << xmlBufferContent(pBuffer) << endl;
}
开发者ID:JohnChu,项目名称:libavg,代码行数:7,代码来源:TrackerConfig.cpp

示例5: as_string

string as_string(xmlNodePtr node) {
    xmlBufferPtr buf = xmlBufferCreate();
    xmlNodeDump(buf,node->doc,node,0,1);
    string result((char*)buf->content);
    xmlBufferFree(buf);
    return result;
}
开发者ID:treiche,项目名称:db_agg,代码行数:7,代码来源:xml.cpp

示例6: info_to_xml

char * info_to_xml(char * name, char * group, char * var)
{
	xmlDoc * doc = NULL;
	xmlNode * rootNode = NULL;
	doc = xmlNewDoc("1.0");
	rootNode = xmlNewNode(NULL, "persons");
	//FILE * file = fopen("newBase.xml", "w");
	char * text = malloc(sizeof(char) * 1000);
	for (int i = 0; i < 1000; i++)
	{
		text[i] = '\0';
	}
	xmlDocSetRootElement(doc, rootNode);
	xmlNewChild(rootNode, NULL, "student", name);
	xmlNewChild(rootNode, NULL, "group", group);
	xmlNewChild(rootNode, NULL, "variant", var);
	xmlBuffer * bufferPtr = xmlBufferCreate();
	xmlNodeDump(bufferPtr, NULL, (xmlNode *)doc, 0, 1);
	strcat(text, bufferPtr->content);
	xmlBufferFree(bufferPtr);
	xmlFreeDoc(doc);
	xmlCleanupParser();
	puts(text);
	return text;
}
开发者ID:bbehrang,项目名称:CoursesRepo,代码行数:25,代码来源:xml.c

示例7: srd_printElementSet

int
srd_printElementSet (xmlDocPtr doc, xmlNodeSet *nodeSet, char **printBuffPtr, int printBuffSize)
{
    xmlNode *cur_node = NULL;
    int n, i;
    xmlChar *value;
    int offset = 0;
    xmlBuffer *buff;
    int size = printBuffSize;
    char *newSpace;

    for (i=0; i < nodeSet->nodeNr; i++) {
    	cur_node = nodeSet->nodeTab[i];
        if (cur_node->type == XML_ELEMENT_NODE) {
           buff = xmlBufferCreate ();
           xmlNodeDump (buff, doc,cur_node, 0, 1 );
           if (size < (offset + strlen((char *)buff->content) + 1)){
        	   size = offset + strlen((char *)buff->content) + 1;
        	   newSpace = (char *)realloc (*printBuffPtr, size);
        	   if (newSpace){
        		   *printBuffPtr = newSpace;
        	   } else {
        		   // unable to allocate space
        		   xmlBufferFree (buff);
        		   return -1;
        	   }
           }
           n = sprintf (*printBuffPtr+offset, "%s", buff->content);
           offset = offset + n;
           xmlBufferFree (buff);
        }
    }
    return (offset);

}
开发者ID:abnicken,项目名称:sysrepod,代码行数:35,代码来源:srd.c

示例8: xmlBufferCreate

char *generate_xml(NFE *nfe, EVP_PKEY *key, X509 *cert) {
	int rc;
	xmlTextWriterPtr writer;
	xmlDocPtr doc;
	xmlBufferPtr buf = xmlBufferCreate();

	writer = xmlNewTextWriterDoc(&doc, 0);
	if (writer == NULL)
		return NULL;
	xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL);
	rc = gen_inf_nfe(writer, nfe);
	if (rc < 0)
		return NULL;
	xmlTextWriterEndDocument(writer);
	char *URI = malloc(sizeof(char) * (strlen(nfe->idnfe->chave) +
		strlen(ID_PREFIX) + 2));
	strcpy(URI, "#");
	strcat(URI, ID_PREFIX);
	strcat(URI, nfe->idnfe->chave);
	rc = sign_xml(doc, key, cert, URI);
	if(rc)
		return NULL;
	xmlNodeDump(buf, NULL, xmlDocGetRootElement(doc), 0, 0);
	nfe->xml = strdup((char*)buf->content);
	return (char*)buf->content;
}
开发者ID:pablogallardo,项目名称:livrenfe,代码行数:26,代码来源:gen_xml.c

示例9: search

VALUE search(VALUE self, VALUE xpathExpr)
{
  VALUE results = rb_ary_new();
  xmlDocPtr doc;
  xmlXPathObjectPtr xpathObj;
  xmlNodeSetPtr nodes;
  xmlNodePtr cur;
  xmlBufferPtr nodeBuffer;
  int size, i;

  Data_Get_Struct(self, xmlDoc, doc);

  xpathObj = eval_and_search(doc, StringValueCStr(xpathExpr));

  if (xpathObj == NULL) { return Qnil; }

  nodes = xpathObj->nodesetval;
  size = (nodes) ? nodes->nodeNr : 0;

  for (i = 0; i < size; ++i) {
    nodeBuffer = xmlBufferCreate();
    xmlNodeDump(nodeBuffer, doc, nodes->nodeTab[i], 0, 1);
    rb_ary_push(results, rb_str_new2(nodeBuffer->content));
    xmlBufferFree(nodeBuffer);
  }

  xmlXPathFreeObject(xpathObj);

  return results;
}
开发者ID:abedra,项目名称:xpather,代码行数:30,代码来源:xpather.c

示例10: xmlBufferCreate

const std::string XMLElement::dump(bool indent) const
{
    xmlBufferPtr buffer = xmlBufferCreate();
    xmlNodeDump(buffer, doc.getRealDocument(), node, 0, indent ? 1 : 0);
    std::string str = std::string((const char *)buffer->content);
    xmlBufferFree(buffer);

    return str;
}
开发者ID:ASP1234,项目名称:Scilabv5.5.2,代码行数:9,代码来源:XMLElement.cpp

示例11: get_xpath_xml

//!
//! Places raw XML result of an xpath query into buf. The query must return
//! only one element.
//!
//! @param[in] xml_path a string containing the path to the XML file to parse
//! @param[in] xpath a string contianing the XPATH expression to evaluate
//! @param[out] buf for the XML string
//! @param[in] buf_len size of the buf
//!
//! @return EUCA_OK or EUCA_ERROR
//!
int get_xpath_xml(const char *xml_path, const char *xpath, char *buf, int buf_len)
{
    int ret = EUCA_ERROR;
    xmlDocPtr doc = NULL;
    xmlXPathContextPtr context = NULL;
    xmlXPathObjectPtr result = NULL;
    xmlNodeSetPtr nodeset = NULL;

    INIT();

    pthread_mutex_lock(&xml_mutex);
    {
        if ((doc = xmlParseFile(xml_path)) != NULL) {
            if ((context = xmlXPathNewContext(doc)) != NULL) {
                if ((result = xmlXPathEvalExpression(((const xmlChar *)xpath), context)) != NULL) {
                    if (!xmlXPathNodeSetIsEmpty(result->nodesetval)) {
                        nodeset = result->nodesetval;
                        if (nodeset->nodeNr > 1) {
                            fprintf(stderr, "multiple matches for '%s' in '%s'\n", xpath, xml_path);
                        } else {
                            xmlNodePtr node = nodeset->nodeTab[0]->xmlChildrenNode;
                            xmlBufferPtr xbuf = xmlBufferCreate();
                            if (xbuf) {
                                int len = xmlNodeDump(xbuf, doc, node, 0, 1);
                                if (len < 0) {
                                    fprintf(stderr, "failed to extract XML from %s\n", xpath);
                                } else if (len > buf_len) {
                                    fprintf(stderr, "insufficient buffer for %s\n", xpath);
                                } else {
                                    char *str = (char *)xmlBufferContent(xbuf);
                                    euca_strncpy(buf, str, buf_len);
                                    ret = EUCA_OK;
                                }
                                xmlBufferFree(xbuf);
                            } else {
                                fprintf(stderr, "failed to allocate XML buffer\n");
                            }
                        }
                    }
                    xmlXPathFreeObject(result);
                } else {
                    fprintf(stderr, "no results for '%s' in '%s'\n", xpath, xml_path);
                }
                xmlXPathFreeContext(context);
            } else {
                fprintf(stderr, "failed to set xpath '%s' context for '%s'\n", xpath, xml_path);
            }
            xmlFreeDoc(doc);
        } else {
            fprintf(stderr, "failed to parse XML in '%s'\n", xml_path);
        }
    }
    pthread_mutex_unlock(&xml_mutex);

    return ret;
}
开发者ID:euca-nightfury,项目名称:eucalyptus,代码行数:67,代码来源:euca_volume.c

示例12: xmlKeepBlanksDefault

std::string XMLConfObj::toString()
{
    xmlIndentTreeOutput = 1;
    xmlKeepBlanksDefault(0);
    xmlBufferPtr xmlBufPtr = xmlBufferCreate();
    xmlNodeDump(xmlBufPtr, documentTree, currentLevel, 0, 1);
    std::string ret = std::string((char *)xmlBufPtr->content, xmlBufPtr->use);
    xmlBufferFree(xmlBufPtr);
    return ret;
}
开发者ID:BackupTheBerlios,项目名称:vermont-svn,代码行数:10,代码来源:confobj.cpp

示例13: epp_getSubtree

char *
epp_getSubtree(void *pool,
		epp_command_data *cdata,
		const char *xpath_expr,
		int position)
{
	char	*subtree;
	xmlBufferPtr	 buf;
	xmlDocPtr	 doc;
	xmlNodePtr	 node;
	xmlXPathObjectPtr	 xpath_obj;
	xmlXPathContextPtr	 xpath_ctx;

	doc = (xmlDocPtr) cdata->parsed_doc;
	xpath_ctx = (xmlXPathContextPtr) cdata->xpath_ctx;

	xpath_obj = xmlXPathEvalExpression(BAD_CAST xpath_expr, xpath_ctx);
	if (xpath_obj == NULL)
		return NULL;
	/* correct position for non-list elements */
	if (position == 0) position++;
	if (xmlXPathNodeSetGetLength(xpath_obj->nodesetval) < position) {
		xmlXPathFreeObject(xpath_obj);
		/* return empty string if the node is not there */
		return epp_strdup(pool, "");
	}

	/*
	 * Get content of problematic tag. It's not so easy task. We have
	 * to declare namespaces defined higher in the tree which are relevant
	 * to the part of document being dumped. Fortunatelly there is a
	 * function from libxml library doing exactly that (xmlreconsiliatens).
	 */
	buf = xmlBufferCreate();
	if (buf == NULL)
		return NULL;
	node = xmlXPathNodeSetItem(xpath_obj->nodesetval, position - 1);
	if (node->ns != NULL) {
		xmlNsPtr	 nsdef;

		nsdef = xmlSearchNs(doc, node, node->ns->prefix);
		if (nsdef != NULL)
			xmlNewNs(node, nsdef->href, nsdef->prefix);
	}
	if (xmlNodeDump(buf, doc, node, 0, 0) < 0)
	{
		xmlXPathFreeObject(xpath_obj);
		xmlBufferFree(buf);
		return NULL;
	}
	subtree = epp_strdup(pool, (char *) buf->content);
	xmlXPathFreeObject(xpath_obj);
	xmlBufferFree(buf);
	return subtree;
}
开发者ID:LANJr4D,项目名称:FRED,代码行数:55,代码来源:epp_xmlcommon.c

示例14: htmlReadMemory

/**
 * レスをIDで抽出してファイルから読み取ってDOM形式にして送り返す
 * @param  const wxString& rawHtml                スレッドのHTML
 * @param  const wxString& extractId		  抽出対象のID
 * @return wxString	   取得したレスの内容
 */
wxString XrossBoardUtil::FindResponseByIndex(const wxString& rawHtml, const wxString& extractIndex) {

     // wxString::mb_str で変換するとWindowsの場合CP932が返ってくるので
     // まずはUTF-8のwxCharBufferに変換してやる
     const wxCharBuffer &cb = rawHtml.utf8_str();
     const htmlDocPtr docPtr = htmlReadMemory(cb.data(), ::strlen(cb.data()), "", "utf-8", 
 					      HTML_PARSE_RECOVER|HTML_PARSE_NOERROR|HTML_PARSE_NOWARNING);

     // HTMLのDOM形式にする
     wxString lumpOfHTML = HTML_HEADER_POPUP;

     if (docPtr)
     {
	  const htmlNodePtr root = xmlDocGetRootElement(docPtr);
	  const htmlNodePtr body = root->children->next;
	  for (htmlNodePtr node = body->children; node != NULL; node = node->next)
	  {
	       if (node->type == XML_ELEMENT_NODE && 
		   xmlStrcasecmp(node->name, (const xmlChar*) "dd") == 0)
	       {
		    const htmlNodePtr dd = node->children;
		    if (DDNodeHasTarget(dd, extractIndex))
		    {
			 xmlBufferPtr buffer = xmlBufferCreate();
			 xmlNodeDump(buffer, docPtr, node->prev, 0, 1);
			 xmlNodeDump(buffer, docPtr, node, 0, 1);
			 lumpOfHTML += wxString::FromUTF8(reinterpret_cast<const char*>(buffer->content));

			 continue;
		    }
	       }
	  }

	  xmlFreeDoc(docPtr);
	  xmlCleanupParser();
     }

     // HTMLソースを加える
     lumpOfHTML += HTML_FOOTER;

     return lumpOfHTML;
}
开发者ID:gitter-badger,项目名称:XrossBoard,代码行数:48,代码来源:xrossboardutil.cpp

示例15: xmlBufferCreate

/*Write - writes xml tree of element to buffer
output: 
data - is set to point to buffer containing xml data
tlength - is set to length of xml data
*/
void CXMLElement::Write(char **data,int *tlength,Bool isformatted)
{
	if (!isinited()) return;
	if (element->doc){
		xmlBufferPtr buf;
		buf = xmlBufferCreate();
		xmlNodeDump(buf, element->doc, element, 0, isformatted);
		*data = (char *)xmlStrdup(xmlBufferContent(buf));
		*tlength = xmlBufferLength(buf);
		xmlBufferFree(buf);
	}
}
开发者ID:alilloyd,项目名称:livecode,代码行数:17,代码来源:xmlelement.cpp


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