DOMDocument* setParser::StringToDOMDocument(char* xmldoc)
{
DOMDocument* xmlDoc;
static const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
DOMImplementation* impl =
DOMImplementationRegistry::getDOMImplementation(gLS);
DOMLSInput* input = impl->createLSInput();
DOMLSParser* setParser =
((DOMImplementationLS*)impl)->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS,
0);
XMLString::trim(xmldoc);
XMLCh* doc = XMLString::transcode(xmldoc);
input->setStringData(doc);
xmlDoc = setParser->parse(input);
xmlDoc->normalize();
XMLString::release( &doc );
return xmlDoc;
}
On Fri, Jul 9, 2010 at 12:31 PM, Ricardo Mendes <[email protected]> wrote:
> Hi,
>
> you can do for instance:
>
> char* setParser::DOMDocumentToString(DOMDocument* xmlDoc)
> {
> const XMLCh gLS[] = { 'L', 'S', chNull };
> DOMImplementation* impl =
> DOMImplementationRegistry::getDOMImplementation(gLS);
> DOMLSSerializer* serializer =
> ((DOMImplementationLS*)impl)->createLSSerializer();
> DOMLSOutput* output = ((DOMImplementationLS*)impl)->createLSOutput();
> output->setEncoding(XMLUni::fgUTF8EncodingString);
> MemBufFormatTarget* mbft = new MemBufFormatTarget;
> output->setByteStream(mbft);
> serializer->write(xmlDoc,output);
> output->release();
> serializer->release();
>
> return (char*)mbft->getRawBuffer();
> }
>
> On Thu, Jul 8, 2010 at 11:04 PM, B.W.H. van Beest <[email protected]> wrote:
>> Hi,
>>
>> Can somebody please explain to me in some detail what I should do if I
>> want to serialise a xercesc::DOMDocument,
>> with the xml-output going to some memory buffer, then parse that xml
>> buffer and validate it against a given schema?
>>
>> I read that the parser (XercesDOMParser or SAXParser) have a parse
>> method "parse( const InputSource&)" method,
>> and that there is a MemBufInputSource derivate class of InputSource, but
>> how do I create an approppriate instance from a DOMDocument?
>>
>>
>> Your help is greatly appreciated.
>>
>> Bertwim
>>
>