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


C++ xmlTextWriterStartDocument函数代码示例

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


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

示例1: xml_init

struct writer * xml_init(FILE * fh) {

	struct writer * result;
	struct xml_writer_private * priv;

	priv = malloc( sizeof( *priv ) );
	if ( ! priv ) {
		fatalx("out of memory\n");
		return NULL;
	}

	priv->xw = xmlNewTextWriterDoc(&(priv->doc), 0);
	if ( ! priv->xw ) {
		fatalx("cannot create xml writer\n");
		return NULL;
	}

	xmlTextWriterSetIndent(priv->xw, 4);

	if (xmlTextWriterStartDocument(priv->xw, NULL, MY_ENCODING, NULL) < 0 ) {
		fatalx("cannot start xml document\n");
		return NULL;
	}

	result = malloc( sizeof( struct writer ) );
	if ( ! result ) {
		fatalx("out of memory\n");
		return NULL;
	}

	result->priv  = priv;
	result->start = xml_start;
	result->attr  = xml_attr;
	result->data  = xml_data;
	result->end   = xml_end;
	result->finish= xml_finish;

	return result;
}
开发者ID:alexshavelev,项目名称:lldpd,代码行数:39,代码来源:xml_writer.c

示例2: xmlNewDoc

void XMLExporter::open(const std::string &_filename, const std::string &_element)
{
	m_doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);
	m_node = xmlNewDocNode(m_doc, NULL, BAD_CAST "root", NULL);
	xmlDocSetRootElement(m_doc, m_node);
	m_writer = xmlNewTextWriterTree(m_doc,m_node, 0); 
	xmlTextWriterStartDocument(m_writer, NULL, MY_ENCODING, NULL);
//	xmlTextWriterStartElement(m_writer, BAD_CAST _element.c_str());
	m_file = _filename;
}
开发者ID:skirk,项目名称:3rdYearMajor,代码行数:10,代码来源:Exporter.cpp

示例3: xmlTextWriterSetIndent

void xml_writer::init(bool indent) {
  // maybe enable indenting
  if (indent) {
    xmlTextWriterSetIndent(pimpl->writer, 1);
  }

  // start the document
  if (xmlTextWriterStartDocument(pimpl->writer, NULL, "UTF-8", NULL) < 0) {
    throw write_error("error creating document element.");
  }
}
开发者ID:dgreyling,项目名称:cgimap,代码行数:11,代码来源:xml_writer.cpp

示例4: xmlTextWriterStartDocument

bool c_XMLWriter::t_startdocument(const String& version /* = "1.0" */,
                                  const String& encoding /* = null_string */,
                                  const String& standalone /* = null_string */) {
  int ret = -1;
  if (m_ptr) {
    ret = xmlTextWriterStartDocument(m_ptr, (const char *)xmls(version),
                                     (const char *)xmls(encoding),
                                     (const char *)xmls(standalone));
  }
  return ret != -1;
}
开发者ID:chethenry,项目名称:hiphop-php,代码行数:11,代码来源:ext_xmlwriter.cpp

示例5: xmlNewTextWriterFilename

XMLBBoxWriter::XMLBBoxWriter(const char* filename):frameCount(0)
{
	open_success=true;
	writer = xmlNewTextWriterFilename(filename, 0);
	if (writer == NULL) {
		printf("testXmlwriterFilename: Error creating the xml writer\n");
		open_success=false;
	}
	rc=xmlTextWriterStartDocument(writer,NULL,ENCODING,NULL);
	rc=xmlTextWriterStartElement(writer, BAD_CAST "dataset");
}
开发者ID:HiranChathura,项目名称:ViDasa,代码行数:11,代码来源:dataReader.cpp

示例6: xml_new_writer

void xml_new_writer(struct xml_writer_private *priv)
{
	priv->xw = xmlNewTextWriterDoc(&(priv->doc), 0);
	if (!priv->xw)
		fatalx("lldpctl", "cannot create xml writer");

	xmlTextWriterSetIndent(priv->xw, 4);

	if (xmlTextWriterStartDocument(priv->xw, NULL, "UTF-8", NULL) < 0 )
		fatalx("lldpctl", "cannot start xml document");
}
开发者ID:alagoutte,项目名称:lldpd,代码行数:11,代码来源:xml_writer.c

示例7: startSBOLDocument

static void startSBOLDocument() {
	resetProcessed();
	createSBOLWriter();
	xmlTextWriterStartDocument(WRITER, NULL, NULL, NULL);
	xmlTextWriterStartElement(WRITER, xmlCharStrdup(NSPREFIX_RDF ":" NODENAME_RDF));
	xmlTextWriterWriteAttribute(WRITER, xmlCharStrdup("xmlns:" NSPREFIX_RDF), xmlCharStrdup(NSURL_RDF));
	xmlTextWriterWriteAttribute(WRITER, xmlCharStrdup("xmlns:" NSPREFIX_RDFS), xmlCharStrdup(NSURL_RDFS));
	xmlTextWriterWriteAttribute(WRITER, xmlCharStrdup("xmlns:" NSPREFIX_SO),   xmlCharStrdup(NSURL_SO));
	xmlTextWriterWriteAttribute(WRITER, xmlCharStrdup("xmlns:" NSPREFIX_SBOL), xmlCharStrdup(NSURL_SBOL));
	indentMore();
}
开发者ID:CytoComp,项目名称:libSBOLc,代码行数:11,代码来源:writer.c

示例8: INSTANCE_METHOD_INJECTION_BUILTIN

bool c_XMLWriter::t_startdocument(CStrRef version /* = "1.0" */,
                                  CStrRef encoding /* = null_string */,
                                  CStrRef standalone /* = null_string */) {
  INSTANCE_METHOD_INJECTION_BUILTIN(XMLWriter, XMLWriter::startdocument);
  int ret = -1;
  if (m_ptr) {
    ret = xmlTextWriterStartDocument(m_ptr, (const char *)xmls(version),
                                     (const char *)xmls(encoding),
                                     (const char *)xmls(standalone));
  }
  return ret != -1;
}
开发者ID:activeingredient,项目名称:hiphop-php,代码行数:12,代码来源:ext_xmlwriter.cpp

示例9: settingsXmlSave

// SAX save settings
short int settingsXmlSave(const char *filename) {

    int rc;
    xmlTextWriterPtr writer;

    // Create a new XmlWriter with no compression
    writer = xmlNewTextWriterFilename(filename, 0);
    if (writer == NULL) return 1;

    // Start document with xml default encoding ISO 8859-1
    rc = xmlTextWriterStartDocument(writer, NULL, XML_ENCODING, NULL);
    if (rc < 0) return 2;

    // Start root node "settings"
    rc = xmlTextWriterStartElement(writer, BAD_CAST "settings");
    if (rc < 0) return 2;

	// Create child node "xap"
    rc = xmlTextWriterStartElement(writer, BAD_CAST "xap");
    if (rc < 0) return 2;
    
	// Write <xap> elements
    rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "iface", "%s", hubConfig->interfacename);
	if (rc < 0) return 4;
	rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "instance", "%s", hubConfig->xap_addr.instance);
	if (rc < 0) return 4;
    rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "hbeatf", "%d", hubConfig->xap_hbeat);
    if (rc < 0) return 4;
	rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "uid", "%s", hubConfig->xap_uid);
    if (rc < 0) return 4;
    rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "port", "%d", hubConfig->xap_port);
    if (rc < 0) return 4;        
    
    // Close node "xap"
    rc = xmlTextWriterEndElement(writer);
    if (rc < 0) return 5;
    
    // Close the rest nodes pending to close
    rc = xmlTextWriterEndDocument(writer);
	if (rc < 0) return 5;

	// Free the writer
    xmlFreeTextWriter(writer);
    
    // Cleanup function for the XML library.
    xmlCleanupParser();
    
    // this is to debug memory for regression tests
    xmlMemoryDump();
    
    return 0;
}
开发者ID:homected,项目名称:homected4pi-v1.0,代码行数:53,代码来源:hub.c

示例10: writeNode

static void writeNode(Serialization *serialization, DFNode *node, int depth)
{
    switch (node->tag) {
        case DOM_DOCUMENT: {
            if (!serialization->html)
                xmlTextWriterStartDocument(serialization->writer,"1.0","UTF-8","yes");
            if (serialization->html)
                xmlTextWriterWriteDTD(serialization->writer,(xmlChar *)"html",NULL,NULL,NULL);
//            xmlTextWriterWriteDTD(writer,
//                                  (xmlChar *)"html",
//                                  (xmlChar *)"-//W3C//DTD XHTML 1.0 Strict//EN",
//                                  (xmlChar *)"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd",
//                                  NULL);
            for (DFNode *child = node->first; child != NULL; child = child->next)
                writeNode(serialization,child,0);
            xmlTextWriterEndDocument(serialization->writer);
            break;
        }
        case DOM_TEXT: {
            if (serialization->indent && ((node->prev != NULL) || (node->next != NULL)))
                xmlTextWriterWriteRawLen(serialization->writer,INDENT,1+depth);
            if (serialization->html && (node->parent != NULL) && (node->parent->tag == HTML_STYLE)) {
                xmlTextWriterWriteRaw(serialization->writer,(const xmlChar *)node->value);
            }
            else {
                xmlTextWriterWriteString(serialization->writer,(const xmlChar *)node->value);
            }
            break;
        }
        case DOM_COMMENT: {
            xmlTextWriterWriteComment(serialization->writer,(const xmlChar *)node->value);
            break;
        }
        case DOM_CDATA: {
            xmlTextWriterWriteCDATA(serialization->writer,(const xmlChar *)node->value);
            break;
        }
        case DOM_PROCESSING_INSTRUCTION: {
            xmlTextWriterWritePI(serialization->writer,
                                 (const xmlChar *)node->target,
                                 (const xmlChar *)node->value);
            break;
        }
        default: {
            if (node->parent == serialization->doc->docNode)
                writeElement(serialization,node,0);
            else
                writeElement(serialization,node,depth);
            break;
        }
    }
}
开发者ID:apache,项目名称:incubator-corinthia,代码行数:52,代码来源:DFXML.c

示例11: temporal_convert_parallel_passages

void temporal_convert_parallel_passages()
// This was used to convert file NT_order_of_OT_Quotations_in_NT.pps to xml.
// Then for converting NT_Parallel_Passages.pps.
// Then for converting OT_Parallel_Passages.pps.
{
  bool set_opened = false;
  xmlBufferPtr buffer = xmlBufferCreate();
  xmlTextWriterPtr writer = xmlNewTextWriterMemory(buffer, 0);
  xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL);
  xmlTextWriterSetIndent(writer, 1);
  xmlTextWriterStartElement(writer, BAD_CAST "ot-parallel-passages");

  ReadText rt("/home/joe/parallel-passages/OT_Parallel_Passages.pps", true);
  for (unsigned int i = 0; i < rt.lines.size(); i++) {
    if (rt.lines[i].find("\\key ") == 0) {
      rt.lines[i].erase(0, 5);
      xmlTextWriterStartElement(writer, BAD_CAST "section");
      xmlTextWriterWriteAttribute(writer, BAD_CAST "title", BAD_CAST rt.lines[i].c_str());
    }
    if (rt.lines[i].find("\\ref ") == 0) {
      if (!set_opened) {
        xmlTextWriterStartElement(writer, BAD_CAST "set");
        set_opened = true;
      }
      xmlTextWriterStartElement(writer, BAD_CAST "reference");
      rt.lines[i].erase(0, 5);
      ustring book, chapter, verse;
      decode_reference(rt.lines[i], book, chapter, verse);
      book = books_id_to_english(books_paratext_to_id(book));
      xmlTextWriterWriteAttribute(writer, BAD_CAST "book", BAD_CAST book.c_str());
      xmlTextWriterWriteAttribute(writer, BAD_CAST "chapter", BAD_CAST chapter.c_str());
      xmlTextWriterWriteAttribute(writer, BAD_CAST "verse", BAD_CAST verse.c_str());
      xmlTextWriterEndElement(writer);
    }
    if (rt.lines[i].empty() || (rt.lines[i].find("\\com") == 0)) {
      xmlTextWriterEndElement(writer);
      set_opened = false;
    }
    if (rt.lines[i].empty()) {
      xmlTextWriterEndElement(writer);
    }
  }

  xmlTextWriterEndDocument(writer);
  xmlTextWriterFlush(writer);
  g_file_set_contents("/home/joe/ot-parallel-passages.xml", (const gchar *)buffer->content, -1, NULL);
  if (writer)
    xmlFreeTextWriter(writer);
  if (buffer)
    xmlBufferFree(buffer);
}
开发者ID:alerque,项目名称:bibledit,代码行数:51,代码来源:temporal.cpp

示例12: xmlBufferCreate

/**
 * @short Prepares the response for propfinds
 * 
 * @param realpath Shared folder
 * @param urlpath URL of the requested propfind
 * @param depth Depth of query, 0 or 1.
 * @param props Properties of the query
 * 
 * @returns An onion_block with the XML data.
 */
onion_block *onion_webdav_write_propfind(const char *basepath, const char *realpath, const char *urlpath, int depth, 
																				 int props){
	onion_block *data=onion_block_new();
	xmlTextWriterPtr writer;
	xmlBufferPtr buf;
	buf = xmlBufferCreate();
	if (buf == NULL) {
		ONION_ERROR("testXmlwriterMemory: Error creating the xml buffer");
		return data;
	}
	writer = xmlNewTextWriterMemory(buf, 0);
	if (writer == NULL) {
		ONION_ERROR("testXmlwriterMemory: Error creating the xml writer");
		return data;
	}
	int error;
	xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL);
	xmlTextWriterStartElement(writer, BAD_CAST "D:multistatus");
		xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns:D" ,BAD_CAST "DAV:");
			error=onion_webdav_write_props(writer, basepath, realpath, urlpath, NULL, props);
			if (depth>0){
				ONION_DEBUG("Get also all files");
				DIR *dir=opendir(realpath);
				if (!dir){
					ONION_ERROR("Error opening dir %s to check files on it", realpath);
				}
				else{
					struct dirent *de;
					while ( (de=readdir(dir)) ){
						if (de->d_name[0]!='.')
							onion_webdav_write_props(writer, basepath, realpath, urlpath, de->d_name, props);
					}
					closedir(dir);
				}
			}
		xmlTextWriterEndElement(writer);
	xmlTextWriterEndElement(writer);
	
	
	xmlTextWriterEndDocument(writer);
	xmlFreeTextWriter(writer);
	
	onion_block_add_str(data, (const char*)buf->content);
	xmlBufferFree(buf);

	if (error){
		onion_block_free(data);
		return NULL;
	}
	return data;
}
开发者ID:hchtym,项目名称:onion,代码行数:61,代码来源:webdav.c

示例13: save_gpx

int save_gpx(const char *fname,GList *save_list)
{
  time_t t=time(NULL);
  struct tm tm;
  GList *l;
  xmlTextWriterPtr writer;
  writer=xmlNewTextWriterFilename(fname,0);
  if (!writer)
    return 0;
  xmlTextWriterStartDocument(writer,NULL,"UTF-8",NULL);
  xmlTextWriterStartElement(writer,(xmlChar *)"gpx");
  xmlTextWriterWriteAttribute(writer,(xmlChar *)"version",(xmlChar *)"1.0");
  xmlTextWriterWriteAttribute(writer,(xmlChar *)"creator",(xmlChar *)PACKAGE " " VERSION);
  xmlTextWriterWriteAttribute(writer,(xmlChar *)"xmlns:xsi",(xmlChar *)"http://www.w3.org/2001/XMLSchema-instance");
  xmlTextWriterWriteAttribute(writer,(xmlChar *)"xmlns",
			      (xmlChar *)"http://www.topografix.com/GPX/1/0");
  xmlTextWriterWriteAttribute(writer,(xmlChar *)"xsi:schemaLocation",(xmlChar *)"http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd");
  tm=*gmtime(&t);
  xmlTextWriterWriteFormatElement(writer,(xmlChar *)"time","%04d-%02d-%02dT%02d:%02d:%02d",
			    tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,
			    tm.tm_hour,tm.tm_min,tm.tm_sec);
  xmlTextWriterStartElement(writer,(xmlChar *)"trk");
  xmlTextWriterStartElement(writer,(xmlChar *)"trkseg");
  for(l=g_list_first(save_list);l;l=g_list_next(l)) {
    struct t_punkt32 *p=(struct t_punkt32 *)l->data;
    xmlTextWriterStartElement(writer,(xmlChar *)"trkpt");
    xmlTextWriterWriteFormatAttribute(writer,(xmlChar *)"lat","%f",
				      p->latt);
    xmlTextWriterWriteFormatAttribute(writer,(xmlChar *)"lon","%f",
				      p->longg);
    if (p->time) {
      t=p->time;
      tm=*gmtime(&t);
      xmlTextWriterWriteFormatElement(writer,(xmlChar*)"time",
				"%04d-%02d-%02dT%02d:%02d:%02d",
				tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,
				tm.tm_hour,tm.tm_min,tm.tm_sec);
    }
    if (p->speed>0)
      xmlTextWriterWriteFormatElement(writer,(xmlChar *)"speed","%f",p->speed*1.852/3.6);
    xmlTextWriterEndElement(writer); /* /trkpt */
    
  }
  xmlTextWriterEndElement(writer); /*trkseg */
  xmlTextWriterEndElement(writer); /* trk */
  xmlTextWriterEndElement(writer); /* gpx */
  xmlTextWriterEndDocument(writer);
  xmlFreeTextWriter(writer);
  return 1;
}
开发者ID:akemnade,项目名称:mumpot,代码行数:50,代码来源:gps.c

示例14: xmls

bool c_XMLWriter::t_startdocument(const String& version /* = "1.0" */,
                                  const String& encoding /* = null_string */,
                                  const String& standalone /* = null_string */) {
  int ret = -1;
  if (m_ptr) {
    const auto pencoding = encoding.empty() ? nullptr : xmls(encoding);
    const auto pstandalone = standalone.empty() ? nullptr : xmls(standalone);
    ret = xmlTextWriterStartDocument(m_ptr,
                                     (const char *)xmls(version),
                                     (const char *)pencoding,
                                     (const char *)pstandalone);
  }
  return ret != -1;
}
开发者ID:asvinours,项目名称:hhvm,代码行数:14,代码来源:ext_xmlwriter.cpp

示例15: xml_writer_write_start_document

/**
 * xml_writer_write_start_document:
 * @writer: A #XmlWriter
 * @version: the xml version ("1.0") or NULL for default ("1.0")
 * @encoding: the encoding or NULL for default
 * @standalone: yes" or "no" or NULL for default
 *
 * Starts a new xml document. You must be at the begging of a
 * stream for this to be successful.
 */
void
xml_writer_write_start_document (XmlWriter   *writer,
                                 const gchar *version,
                                 const gchar *encoding,
                                 const gchar *standalone)
{
  XmlWriterPrivate *priv;
  
  g_return_if_fail (XML_IS_WRITER (writer));
  
  priv = writer->priv;
  
  if (priv->writer)
    xmlTextWriterStartDocument (priv->writer, version, encoding, standalone);
}
开发者ID:chergert,项目名称:simply-news,代码行数:25,代码来源:xml-writer.c


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