Click here to Skip to main content
15,887,313 members
Articles / Programming Languages / XML

UTF-8 encoded XML file/stream processing

Rate me:
Please Sign up or sign in to vote.
3.58/5 (9 votes)
5 Jan 20072 min read 84.6K   5.9K   31  
Process an UTF-8 encoded XML file or stream; read group & attribute values; write & delete grps, attribs, values & comments.
// ============================================================================	//
//				T E S T _ m a i n . c p p			//
// ----------------------------------------------------------------------------	//
// ============================================================================	//
#define __main_cpp__			// cause h file to declare globals
#include "TEST_main.h"			// definitions, typedefs, global data & prototypes
#include "TEST_XMLsbs.h"
#include <stdio.h>			// for printf
#include <conio.h>			// for _kbhit
#include <windows.h>			// for Sleep

// ============================================================================	//
//				m a i n						//
// ============================================================================	//
void main (int argc, const char *argv[])
{
    printf("Run of %s",WhoIm);
    printf("\n XM8dll version %s",XM8_getVersion());printf(", dated %s",XM8_getDate());


    if (TEST_processIniFile())
    {
	if (TEST_processIniFile2())
	{
	    if (TEST_processIniFile3())
	    {
		if (TEST_processIniFile4())
		{
		}
		else printf("\n%s","Some kind of 4th TEST_processIniFile failure");
	    }
	    else printf("\n%s","Some kind of 3rd TEST_processIniFile failure");
	}
	else printf("\n%s","Some kind of 2nd TEST_processIniFile failure");
    }
    else printf("\n%s","Some kind of 1st TEST_processIniFile failure");

//  ===================================================================	//
//  Exit tidily								//
//  ===================================================================	//
    printf("\n%s exiting tidily",WhoIm);

    printf("\n\n\n\nType x followed by y to exit");
    bool xitRqd = false; long stage=0;
    while(!xitRqd)
    {
	if (_kbhit())
	{
	    char x = _getche();

		 if ((x&~0x20)=='X' )	    { stage=1;printf("\nExit requested, are you sure ? ");}
	    else if ((x&~0x20)=='Y'&&stage==1)stage=2;
	    else if ( x	      !='\n')	      stage=0;

	    if (stage == 2) xitRqd = true;
	}
	else Sleep(100);
    }
}


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United Kingdom United Kingdom
BSc (St.Andrews(1963-67))
MSCE
Systems Programmer 39+yrs
Married to first wife 35yrs & counting, four grown-up children
Religious opinions similar to MelG's
It is not the gnosis, but the praxis must be the fruit. (Aristotle)

Comments and Discussions