Look at the MemParse example, in particular referring to MemBufInputSource:
 
   MemBufInputSource* memBufIS = new MemBufInputSource   (
        (const XMLByte*)gXMLInMemBuf
        , strlen(gXMLInMemBuf)
        , gMemBufId
        , false  );
 
where in this case, gXMLInMemBuf represents a const char* that requires parsing. This approach worked fine for me.
 
Regards,
 
Steve Westwood

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 19 March 2002 09:11
To: [EMAIL PROTECTED]
Subject: parse std::string (xml in string)


Hi all,

How is it possible to parse the contents of a normal std::string...?

example:

01:        string myString ="<?xml version=/"1.0/"?><test><blah>blah</blah></test>"; // or something....
02:        try {
03:                XMLPlatformUtils::Initialize();
04:            } catch (XMLException& e) {
05:                cerr << "Error during init!" << endl
06:                     << "Message: " << e.getMessage() << endl;
07:            }
08:        
09:            SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
10:            SAX2ElementHandler myHandler;
11:            parser->setContentHandler(&myHandler);
12:            parser->setErrorHandler(&myHandler);
13:        
14:            try {
15:                parser->parse(....?????..........); // What to put here? myString does not work...
16:            } catch (const XMLException& e) {
17:                cerr << "Error during parse..." << endl;
18:           } catch (...) {
19:                cerr << "Other error..." << endl;
20:            }


So my problem is what to do on line 15...

Many thanks for your help!

Harm de Laat
Informatiefabriek
The Netherlands


Reply via email to