You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Eric Ulevik <ea...@fast.fujitsu.com.au> on 2000/02/03 09:25:07 UTC

Parsing XML Strings

What is the right way to parse a XML string using Xerces-c?

I would like to process XML from char*, std::string, wchar_t*.

Thanks,

Eric Ulevik


Re: Parsing XML Strings

Posted by Eric Ulevik <ea...@fast.fujitsu.com.au>.
From: Michael Mason <mg...@decisionsoft.com>
> > What is the right way to parse a XML string using Xerces-c?
> > I would like to process XML from char*, std::string, wchar_t*.
> 
> You can use MemBufInputSource like this:
> 
> SAXParser *parser = new SAXParser();
> MemBufInputSource *memBufIS = new MemBufInputSource((const XMLByte
> *)xml_buf, strlen(xml_buf), "My XML Data", false);

Is there any way of parsing a XML string using Xerces-c and 
DOM rather than SAX?



Re: Parsing XML Strings

Posted by Michael Mason <mg...@decisionsoft.com>.
> Eric Ulevik wrote:
> 
> What is the right way to parse a XML string using Xerces-c?
> 
> I would like to process XML from char*, std::string, wchar_t*.

You can use MemBufInputSource like this:

SAXParser *parser = new SAXParser();
[etc, set up parser properly]

char* xml_buf = "<xml> my xml document </xml>";
MemBufInputSource *memBufIS = new MemBufInputSource((const XMLByte
*)xml_buf, strlen(xml_buf), "My XML Data", false);
try {
	parser->parse(*memBufIS);
}
catch(some exception) {
	[etc]
}

I think the MemParse sample shows the full code.

HTH,
Mike.

-- 
Mike Mason, Software Engineer
XML Script Development Team                    Office: 44-1865-203192
http://www.xmlscript.org/                      Mobile: 44-7050-288923