简体   繁体   中英

Using Xerces-C++ to perform an HTTP Request

I've been googling but can't seem to find information on this… I think it's possible because I remember seeing something about this. I'm already using xercesc to parse a XML document (using SAX2). I wanted to replace libcurl with xerces for the HTTP request I'm performing (this HTTP request returns the XML I need to parse). As I said, I googled around and can't seem to find an example of how to accomplish this. I've also looked into the library documentation, but I'm unsure as to which classes I should use. Can anyone help me out with this? Is it possible?

Thanks!

1: Include following header:

#include <xercesc/framework/URLInputSource.hpp>

2: Create instance of URLInputSource by passing http url as an argument:

URLInputSource src( "http://localhost:8080/sampledata-basic.xml" );

3: Pass this instance to "parse" method:

SAXParser* parser = new SAXParser;
//few more statements may go here
parser->parse(src);

NOTE: By default it will not support "https" url. If you want that functionality you need to rebuild the xerces with curl or winsock etc. see: http://xerces.apache.org/xerces-c/build-3.html for build options.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM