Main Page Class Hierarchy Compound List File List Compound Members File Members Related Pages

# xmlreformat.cpp

    00001 #include "cpl_minixml.h"
    00002
    00003 int main( int argc, char **argv )
    00004
    00005 {
    00006     CPLXMLNode *poTree;
    00007     char       szXML[1000000];
    00008     FILE       *fp;
    00009     int        nLen;
    00010
    00011     if( argc == 1 )
    00012         fp = stdin;
    00013     else if( argv[1][0] == '-' )
    00014     {
    00015         printf( "Usage: xmlreformat [filename]\n" );
    00016         exit( 0 );
    00017     }
    00018     else
    00019     {
    00020         fp = fopen( argv[1], "rt" );
    00021         if( fp == NULL )
    00022         {
    00023             printf( "Failed to open file %s.\n", argv[1] );
    00024             exit( 1 );
    00025         }
    00026     }
    00027
    00028     nLen = fread( szXML, 1, sizeof(szXML), fp );
    00029
    00030     if( fp != stdin )
    00031         fclose( fp );
    00032
    00033     szXML[nLen] = '\0';
    00034
    00035     poTree = CPLParseXMLString( szXML );
    00036     if( poTree != NULL )
    00037         printf( "%s", CPLSerializeXMLTree( poTree ) );
    00038 }