// ---------------------------------------------------------------------- // main() for printing files named on the command line // ---------------------------------------------------------------------- int main(int argc, char* argv[]) { for (int i=1; i<argc; i++) { dump_to_stdout(argv[i]); } return 0; }
void XMLTester::dump_to_stdout( TiXmlNode* pParent, unsigned int indent) { if ( !pParent ) return; TiXmlNode* pChild; TiXmlText* pText; int t = pParent->Type(); printf( "%s", xml_getIndent(indent)); int num; switch ( t ) { case TiXmlNode::DOCUMENT: printf( "Document" ); break; case TiXmlNode::ELEMENT: printf( "Element [%s]", pParent->Value() ); num=dump_attribs_to_stdout(pParent->ToElement(), indent+1); switch(num) { case 0: printf( " (No attributes)"); break; case 1: printf( "%s1 attribute", getIndentAlt(indent)); break; default: printf( "%s%d attributes", getIndentAlt(indent), num); break; } break; case TiXmlNode::COMMENT: printf( "Comment: [%s]", pParent->Value()); break; case TiXmlNode::UNKNOWN: printf( "Unknown" ); break; case TiXmlNode::TEXT: pText = pParent->ToText(); printf( "Text: [%s]", pText->Value() ); break; case TiXmlNode::DECLARATION: printf( "Declaration" ); break; default: break; } printf( "\n" ); for ( pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) { dump_to_stdout( pChild, indent+1 ); } }
int _tmain(int argc, _TCHAR* argv[]) { printf("hello world\n"); TiXmlDocument doc( "test.xml" ); doc.LoadFile(); dump_to_stdout( &doc ); for(;;); return 0; }
// load the named file and dump its structure to STDOUT void dump_to_stdout(const char* pFilename) { TiXmlDocument doc(pFilename); bool loadOkay = doc.LoadFile(); if (loadOkay) { printf("\n%s:\n", pFilename); dump_to_stdout(&doc); // defined later in the tutorial } else { printf("Failed to load file \"%s\"\n", pFilename); } }
// load the named file and dump its structure to STDOUT void xmlStructure::dump_to_stdout ( const char* pFilename ) { TiXmlDocument doc ( pFilename ); bool loadOkay = doc.LoadFile ( TIXML_ENCODING_UTF8 ); if ( loadOkay ) { printf ( "\n%s:\n", pFilename ); dump_to_stdout ( &doc ); // defined later in the tutorial } else { printf ( "Failed to load file \"%s\"\n", pFilename ); } }