/* This is simple demonstration of how to use expat. This program
-reads an XML document from standard input and writes a line with the
-name of each element to standard output indenting child elements by
-one tab stop more than their parent element. */
+ reads an XML document from standard input and writes a line with
+ the name of each element to standard output indenting child
+ elements by one tab stop more than their parent element.
+*/
#include <stdio.h>
#include "expat.h"
done = len < sizeof(buf);
if (!XML_Parse(parser, buf, len, done)) {
fprintf(stderr,
- "%s at line %d\n",
- XML_ErrorString(XML_GetErrorCode(parser)),
- XML_GetCurrentLineNumber(parser));
+ "%s at line %d\n",
+ XML_ErrorString(XML_GetErrorCode(parser)),
+ XML_GetCurrentLineNumber(parser));
return 1;
}
} while (!done);
#include <stdio.h>
#include <expat.h>
-#define BUFFSIZE 8192
+#define BUFFSIZE 8192
char Buff[BUFFSIZE];
int Depth;
static void
-start(void *data, const char *el, const char **attr) {
+start(void *data, const char *el, const char **attr)
+{
int i;
for (i = 0; i < Depth; i++)
printf("\n");
Depth++;
-} /* End of start handler */
+}
static void
-end(void *data, const char *el) {
+end(void *data, const char *el)
+{
Depth--;
-} /* End of end handler */
+}
int
-main(int argc, char *argv[]) {
+main(int argc, char *argv[])
+{
XML_Parser p = XML_ParserCreate(NULL);
if (! p) {
fprintf(stderr, "Couldn't allocate memory for parser\n");
if (! XML_Parse(p, Buff, len, done)) {
fprintf(stderr, "Parse error at line %d:\n%s\n",
- XML_GetCurrentLineNumber(p),
- XML_ErrorString(XML_GetErrorCode(p)));
+ XML_GetCurrentLineNumber(p),
+ XML_ErrorString(XML_GetErrorCode(p)));
exit(-1);
}
break;
}
return 0;
-} /* End of main */
-
+}