You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Carlos Bazílio <ca...@yahoo.com.br> on 2003/10/24 16:05:31 UTC
parsing strings
Hi all,
I'm a newbie at Xerces. Since I've started using Xerces, I parsed my XML files using parseURI method from DOMBuilder class. Now I wish to parse a XML provided by a string (char *). How can I do that using DOMBuilder ? Is DOMInputSource a solution ? How can I use it ?
Thanks in advance,
Carlos
---------------------------------
Yahoo! Mail - o melhor webmail do Brasil. Saiba mais!
Re: parsing strings
Posted by Carlos Bazílio <ca...@yahoo.com.br>.
Sean,
Sorry for late replying.
When you sent this message I had already found a similar solution. Now I test your solution and it also works fine.
Thanks a lot anyway.
Carlos
Sean Kelly <se...@ffwd.cx> wrote:
On Fri, 24 Oct 2003, [iso-8859-1] Carlos Bazílio wrote:
>
> I'm a newbie at Xerces. Since I've started using Xerces, I parsed my XML files using parseURI method from DOMBuilder class. Now I wish to parse a XML provided by a string (char *). How can I do that using DOMBuilder ? Is DOMInputSource a solution ? How can I use it ?
I've only ever used the SAX parser, but I imagine the method is the same.
Here's an example of how to parse data in a std::string:
#include
...
std::string buf( "" );
MemBufInputSource is( reinterpret_cast( buf.c_str() ),
buf.size(),
"My Parser" );
reader->parse( is );
Sean
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
---------------------------------
Yahoo! Mail - 6MB, anti-spam e antivírus gratuito. Crie sua conta agora!
Re: parsing strings
Posted by Sean Kelly <se...@ffwd.cx>.
On Fri, 24 Oct 2003, [iso-8859-1] Carlos Baz�lio wrote:
>
> I'm a newbie at Xerces. Since I've started using Xerces, I parsed my XML files using parseURI method from DOMBuilder class. Now I wish to parse a XML provided by a string (char *). How can I do that using DOMBuilder ? Is DOMInputSource a solution ? How can I use it ?
I've only ever used the SAX parser, but I imagine the method is the same.
Here's an example of how to parse data in a std::string:
#include <xercesc/framework/MemBufInputSource.hpp>
...
std::string buf( "<foo></foo>" );
MemBufInputSource is( reinterpret_cast<XMLByte const*>( buf.c_str() ),
buf.size(),
"My Parser" );
reader->parse( is );
Sean
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org