#include <iostream>
#include <cstdlib>
#ifdef CCXX_NAMESPACES
#endif
{
private:
void httpHeader(const char *header, const char *value) {
cout << "HEADER " << header << "=" << value << endl;
}
int read(unsigned char *buffer, size_t len) {
URLStream::read((char *)buffer, len);
len = gcount();
return len;
}
void startDocument(void) {
cout << "START DOCUMENT" << endl;
}
void endDocument(void) {
cout << "END DOCUMENT" << endl;
}
void characters(const unsigned char *text, size_t len) {
cout << "CHARS=";
while(len--)
cout << *(text++);
cout << endl;
}
void comment(const char *text) {
cout << "COMMENT=" << text << endl;
}
void startElement(const unsigned char *name, const unsigned char **attr) {
cout << "<" << name;
if(attr) {
while(*attr) {
cout << " " << *(attr++);
cout << "=" << *(attr++);
}
}
cout << ">" << endl;
}
void endElement(const unsigned char *name) {
cout << "</" << name << ">" << endl;
}
public:
void Close(void) {
URLStream::close();
}
};
int main(int argc, char **argv)
{
myXMLParser xml;
#ifdef CCXX_EXCEPTIONS
try {
#endif
while(--argc) {
++argv;
cout << "fetching " << *argv << endl;
status = xml.get(*argv);
if(status) {
cout << "failed; reason=" << status << endl;
xml.Close();
continue;
}
cout << "Parsing..." << endl;
if(!xml.parse())
cout << "not well formed..." << endl;
xml.Close();
cout << ends;
}
#ifdef CCXX_EXCEPTIONS
}
catch(...) {
cerr << "url " << *argv << " failed" << endl;
}
#endif
}