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


C++ TiXmlNode::Print方法代码示例

本文整理汇总了C++中TiXmlNode::Print方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlNode::Print方法的具体用法?C++ TiXmlNode::Print怎么用?C++ TiXmlNode::Print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TiXmlNode的用法示例。


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

示例1: loadFromXML

/**
* 从xml文件中读取“键-值”对 load "key-value" from xml file
* @param filename 读取的xml文件,必须是按照规定的格式
* @return 布尔值 读取成功与否
*/
bool Properties::loadFromXML(const string filename)
{
	TiXmlDocument doc(filename.c_str());
	bool loadOkay = doc.LoadFile();//以utf-8格式读取xml文件
	if (!loadOkay)
	{
		return false;
	}
	TiXmlNode *node = doc.FirstChild("properties");
        #ifdef DEBUG_PROPERTIES_H
	node->Print(stdout, 1);
	cout << endl;
        #endif
	TiXmlElement* propertiesElement = node->ToElement();
	for(TiXmlElement *it = propertiesElement->FirstChildElement("entry")
		; it!=NULL ;
		it = it->NextSiblingElement("entry")
		)
	{
		TiXmlAttribute *att = it->FirstAttribute();
		this->setProperty(att->Value(), it->GetText());
		#ifdef DEBUG_PROPERTIES_H
		cout << "[" << att->Name() << ":" << att->Value() << "->" << it->GetText() << "]" << endl;
                #endif
	}
	return true;
}
开发者ID:shlice,项目名称:libproperties,代码行数:32,代码来源:libproperties.cpp

示例2: Print

void TiXmlElement::Print(FILE* cfile, int depth) const
{
    int i;
    assert(cfile);

    for (i = 0; i < depth; i++)
    {
        fprintf(cfile, "    ");
    }

    fprintf(cfile, "<%s", value.c_str());

    const TiXmlAttribute* attrib;

    for (attrib = attributeSet.First(); attrib; attrib = attrib->Next())
    {
        fprintf(cfile, " ");
        attrib->Print(cfile, depth);
    }

    // There are 3 different formatting approaches:
    // 1) An element without children is printed as a <foo /> node
    // 2) An element with only a text child is printed as <foo> text </foo>
    // 3) An element with children is printed on multiple lines.
    TiXmlNode* node;

    if (!firstChild)
    {
        fprintf(cfile, " />");
    }
    else if (firstChild == lastChild && firstChild->ToText())
    {
        fprintf(cfile, ">");
        firstChild->Print(cfile, depth + 1);
        fprintf(cfile, "</%s>", value.c_str());
    }
    else
    {
        fprintf(cfile, ">");

        for (node = firstChild; node; node = node->NextSibling())
        {
            if (!node->ToText())
            {
                fprintf(cfile, "\n");
            }

            node->Print(cfile, depth + 1);
        }

        fprintf(cfile, "\n");

        for (i = 0; i < depth; ++i)
        {
            fprintf(cfile, "    ");
        }

        fprintf(cfile, "</%s>", value.c_str());
    }
}
开发者ID:fish199902,项目名称:Flow,代码行数:60,代码来源:tinyxml.cpp

示例3: Print

void TiXmlDocument::Print( FILE* cfile, int depth ) const
{
	TiXmlNode* node;
	for ( node=FirstChild(); node; node=node->NextSibling() )
	{
		node->Print( cfile, depth );
		generic_fprintf( cfile, TEXT("\n") );
	}
}
开发者ID:hhypgfadwr,项目名称:nppPluginManager,代码行数:9,代码来源:tinyxml.cpp

示例4: Print

void TiXmlDocument::Print( FILE* fp, int )
{
	TiXmlNode* node;
	for ( node=FirstChild(); node; node=node->NextSibling() )
	{
		node->Print( fp, 0 );
		fprintf( fp, "\n" );
	}
}
开发者ID:chikanamakalaka,项目名称:pacman-sdl,代码行数:9,代码来源:tinyxml.cpp

示例5: Print

void TiXmlElement::Print( FileOps *f, int depth ) const
{
	const char *newLine = "\n";
	const char *tabSpacer = "   ";
	const char *startTag = "<";
	const char *startEndTag = "</";
	const char *closeEmptyElement = " />";
	const char *closeTag = ">";
	const char *singleSpace = " ";
	int i;
	assert( f );
	for ( i=0; i<depth; i++ ) {
		f->write(tabSpacer, 3, 1);
	}
	f->write(startTag, 1, 1);
	f->write(value.c_str(), value.size(), 1);

	const TiXmlAttribute* attrib;
	for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
	{
		f->write(singleSpace, 1, 1);
		attrib->Print( f, depth );
	}

	// There are 3 different formatting approaches:
	// 1) An element without children is printed as a <foo /> node
	// 2) An element with only a text child is printed as <foo> text </foo>
	// 3) An element with children is printed on multiple lines.
	TiXmlNode* node;
	if ( !firstChild )
	{
		f->write(closeEmptyElement, 3, 1);
	}
	else if ( firstChild == lastChild && firstChild->ToText() )
	{
		f->write(closeTag, 1, 1);
		firstChild->Print( f, depth + 1 );
		f->write(startEndTag, 2, 1);
		f->write(value.c_str(), value.size(), 1);
		f->write(closeTag, 1, 1);
	}
	else
	{
		f->write(closeTag, 1, 1);

		for ( node = firstChild; node; node=node->NextSibling() )
		{
			if ( !node->ToText() )
			{
				f->write(newLine, strlen(newLine), 1);
			}
			node->Print( f, depth+1 );
		}
		f->write(newLine, strlen(newLine), 1);
		for( i=0; i<depth; ++i ) {
			f->write(tabSpacer, 3, 1);
		}
		f->write(startEndTag, 2, 1);
		f->write(value.c_str(), value.size(), 1);
		f->write(closeTag, 1, 1);
	}
}
开发者ID:MoLAoS,项目名称:Mandate,代码行数:62,代码来源:tinyxml.cpp


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