Hi João,

i hope the code below is a helping hand.
i did it that way and it worked.
"pToContent" is an LPCTSTR and contains the string i want to parse.


Best regards
Mirko

 
    static const XMLCh gLS[] = { xercesc::chLatin_L, xercesc::chLatin_S, 
xercesc::chNull };
    xercesc::DOMImplementation *impl = 
xercesc::DOMImplementationRegistry::getDOMImplementation(gLS);
    xercesc::DOMBuilder *parser = 
((xercesc::DOMImplementationLS*)impl)->createDOMBuilder(xercesc::DOMImplementationLS::MODE_SYNCHRONOUS,
 0);

    xercesc::DOMInputSource* buffer =
    new xercesc::Wrapper4InputSource(new xercesc::MemBufInputSource((const 
XMLByte*)pToContent,
    _tcslen((const char*)pToContent)*sizeof(TCHAR),"XMLBuffer", false));

    buffer->setEncoding(L"ISO-8859-1");

    xercesc::DOMDocument* pToDoc = parser->parse(*buffer);



-----Ursprüngliche Nachricht-----
Von: João Graça [mailto:[EMAIL PROTECTED] 
Gesendet: Mittwoch, 16. März 2005 04:01
An: xerces-c-dev@xml.apache.org
Betreff: Getting a parser from a string


Hello,

I am trying to start a parser from a std::string because this is what i receive 
from a xml rpc channel.

The problem is that i already have tried to use DomBuilder, MemBufInputSource 
with and without wrappers and i can't make it. Could someone help me with this 
problem, like sugesting what i should properly do. I have read all the 
documentation several times and i can't figure it out.

I appreciate your atention,
Best regards,
João Graça

PS: I send i little bit of code from one of my experiment so that you can see 
what i am trying to do.

 DOMBuilder* parser = 
((DOMImplementationLS*)_impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS,
0);
 
  const char * msg = analysisXml.c_str();
  MemBufInputSource* memBufIS = new MemBufInputSource
    (
        (const XMLByte*)msg
        , strlen(msg)
        , "repository"
        , false
    );
  Wrapper4DOMInputSource domISWrapper(memBufIS);
  //  Wrapper4DOMInputSource domISWrapper(inputSource);
  DOMDocument *doc = 0;
   try {
            doc = parser->parse(domISWrapper);
        }
        catch (const XMLException& toCatch) {
            char* message = XMLString::transcode(toCatch.getMessage());
            cout << "Exception message is: \n"
                 << message << "\n";
            XMLString::release(&message);
            return 0;
        }
 
   ///Build domain model from dom node

  return 0;

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to