本文整理汇总了C++中XMLAttribute::ToFile方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLAttribute::ToFile方法的具体用法?C++ XMLAttribute::ToFile怎么用?C++ XMLAttribute::ToFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLAttribute
的用法示例。
在下文中一共展示了XMLAttribute::ToFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToFile
//来自:TinyXML
void XMLElement::ToFile(FILE *file,int blankdepth)
{
int i;
for ( i = 0; i < blankdepth; i++ )
{
fprintf( file, " " );
}
fprintf_s( file, "<%s", value.c_str() );
XMLAttribute* attri = NULL;
for ( attri = attributes.First(); attri; attri = attri->Next() )
{
fprintf_s( file, " " );
attri->ToFile( file, blankdepth );
}
// 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.
if ( !firstChild )
{
fprintf_s( file, " />" );
}
else if ( firstChild == lastChild && firstChild->ToText() )
{
fprintf_s( file, ">" );
firstChild->ToFile( file, blankdepth + 1 );
fprintf_s( file, "</%s>", value.c_str() );
}
else
{
XMLNode* node = NULL;
fprintf_s( file, ">" );
for ( node = firstChild; node; node=node->NextSibling() )
{
if ( !node->ToText() )
{
fprintf_s( file, "\n" );
}
node->ToFile( file, blankdepth + 1 );
}
fprintf_s( file, "\n" );
for( i=0; i < blankdepth; ++i )
fprintf_s( file, " " );
fprintf_s( file, "</%s>", value.c_str() );
}
}