int main(int argc, char * argv[]) { genxWriter w = genxNew(NULL, NULL, NULL); genxElement dates, date; genxAttribute yyyy, mm; genxNamespace ns; genxStatus status; int i; char year[100], month[100]; if (!(ns = genxDeclareNamespace(w, "http://example.org/dd", "dd", &status))) oops(w); if (!(dates = genxDeclareElement(w, ns, "dates", &status))) oops(w); if (!(date = genxDeclareElement(w, NULL, "date", &status))) oops(w); if (!(yyyy = genxDeclareAttribute(w, NULL, "yyyy", &status))) oops(w); if (!(mm = genxDeclareAttribute(w, NULL, "mm", &status))) oops(w); if (genxStartDocFile(w, stdout) || genxStartElement(dates) || genxAddText(w, "\n")) oops(w); for (i = 0; i < 1000000; i++) { sprintf(year, "%d", 1900 + (random() % 100)); sprintf(month, "%02d", 1 + (random() % 12)); if (genxStartElement(date) || genxAddAttribute(yyyy, year) || genxAddAttribute(mm, month) || genxEndElement(w) || genxAddText(w, "\n ")) oops(w); } if (genxEndElement(w)) oops(w); if (genxEndDocument(w)) oops(w); }
int main ( void ) { genxWriter w; genxElement header; genxElement body; genxElement html; genxStatus status; int n; PVARTEXT pvt = VarTextCreate(); w = genxNew(NULL,NULL,NULL); genxSetUserData( w, (void*)pvt ); html = genxDeclareElement( w, NULL, (constUtf8)"HTML", &status ); header = genxDeclareElement( w, NULL, (constUtf8)"header", &status ); body = genxDeclareElement( w, NULL, (constUtf8)"body", &status ); genxStartDocSender( w, &senderprocs ); n = genxPI( w, "xml", "version=\"1.0\" encoding=\"UTF-8\"" ); printf( "result:%d\n", n ); genxStartElement( html ); { genxStartElement( header ); genxAddText( w, "Header Here" ); genxEndElement( w ); genxStartElement( body ); genxAddText( w, "body Here" ); genxEndElement( w ); } genxEndElement( w ); genxEndDocument( w ); printf( "Result Document:\n\n" ); printf( "%s", GetText( VarTextPeek( pvt ) ) ); return 0; }