- From: cvb <bancroft@america.net>
- Date: Sat, 25 Nov 2000 11:47:49 -0500
- To: www-lib@w3.org
- CC: Proxtend <jfisher@proxtend.com>
- Message-ID: <3A1FED35.7BA2B02B@america.net>
Proxtend wrote:
> Any Ideas? success stories?
Hurrms, just as an experiment I modified the Element callbacks as follows :
int balance = 0;
int count = 0;
int depth = 0;
/*
-------------------------------------------------------------------------
*/
/* EXPAT HANDLERS */
/*
-------------------------------------------------------------------------
*/
PRIVATE void XML_startElement (void * userData,
const XML_Char * name, const XML_Char ** atts)
{
/*
HTPrint("Start....... %s\n", name ? name : "<null>");
*/
balance ++;
count ++;
if ( depth < balance ) depth = balance;
}
PRIVATE void XML_endElement (void * userData,
const XML_Char * name)
{
/*
HTPrint("End......... %s\n", name ? name : "<null>");
*/
balance --;
}
Then I modified the terminate handler to report these collected numbers as
follows :
PRIVATE int terminate_handler (HTRequest * request, HTResponse *
response,
void * param, int status)
{
/* We are done with this request */
HTRequest_delete(request);
/*
HTPrint("If you didn't see any tags then it is likely that
your document wasn't xml\n");
*/
/* report balance and depth */
HTPrint( "There were %d Element tags, which were %s balanced and
reached a depth of %d\n",
count, ( balance ? "not" : "" ), depth );
/* Terminate libwww */
HTProfile_delete();
exit(0);
}
This gave the following output when run :
[bancroft@frege Examples]$ ./showxml
http://ai.uga.edu/~bancroft/pub/dca.xml
Looking up ai.uga.edu
Looking up ai.uga.edu
Contacting ai.uga.edu
Reading...
Read (49% of 2K)
Done!
There were 41 Element tags, which were balanced and reached a depth
of 3
Along the way, I did notice that the libtool does not play nicely with gdb.
What is up with
[bancroft@frege Examples]$ nm showxml
nm: showxml: File format not recognized
More,
l8r,
v
Received on Saturday, 25 November 2000 11:48:11 UTC