There is an example that does that. The code I use is something like this: //Load a DOMDocument from a utf-8 string const std::string xmlfile; //The source UTF-8 encoded xml file DOMDocument* rslt = NULL; //The resulting DOMDocument string err_message; //For parse errors if ( ! xmlfile.empty() ) { const XMLCh xml_str[] = { chLatin_X, chLatin_M, chLatin_L, chNull }; AutoRelease<DOMLSInput> input(((DOMImplementationLS*)impl)->createLSInput()); //impl is from a getDOMImplementation XMLByte* xmlraw = (XMLByte*)(xmlfile.c_str()); MemBufInputSource* mbis = new MemBufInputSource(xmlraw,xmlfile.size(), xml_str); mbis->setCopyBufToStream(false); input->setByteStream(mbis); input->setEncoding(XMLUni::fgUTF8EncodingString); try { rslt = parser->parse(input); //parser is a DOMLSParser* } catch (DOMLSException e) { Manager::transcode(e.getMessage(),err_message); //use your preferred transcoder here } catch (DOMException e) { Manager::transcode(e.getMessage(),err_message); //use your preferred transcoder here. } catch ( ... ) { err_message = "Some load error occured with an xml file."; } delete mbis; mbis=NULL; }
> > Hi Folks: > > XercesDOMParser's parse() seems to require a file name for an argument. > > I want to parse XML extracted from in an SQL blob. I'm currently > extracting the XML into an std::string. I can convert it to an std::wstring > or feed it to a stream. > > How do I parse XML that's in memory, and not in a file? > > Thanks > Larry > > > -- > View this message in context: > http://old.nabble.com/Newbie---Parsing-XML-String--tp34626020p34626020.html > Sent from the Xerces - C - Users mailing list archive at Nabble.com. >